Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. DependencyProperty problem

DependencyProperty problem

Scheduled Pinned Locked Moved WPF
csharpvisual-studiohelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    schiebel t
    wrote on last edited by
    #1

    Hello all, Im working on an ColorPicker user control and have problems registering DependencyPropertys. I try to register a new DependencyProperty in Visual Studio 2008 and all is working fine so far. Now i open Expression blend, add an reference to the ColorPicker.dll, and add a new instance to the window. When i now build the solution i get an exeption: "the property IsCurrentColor has allready been registerd from _ColorPicker" and the usercontrol cant anymore viewed in expression blend. Im a little confused because the application anyway started and all is working. Here is a little code of mine.

    public partial class _ColorPicker
    {
    private readonly DependencyProperty IsCurrentColorProperty;

        public \_ColorPicker()
    {
            this.InitializeComponent();            
    
                IsCurrentColorProperty = DependencyProperty.Register(
                "IsCurrentColor", typeof(Color), typeof(\_ColorPicker),
                new FrameworkPropertyMetadata(Color.FromRgb(255, 255, 255),
                new PropertyChangedCallback(OnIsCurrentColorChanged)));
        }
        private void OnIsCurrentColorChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            SetColorInfos((Color)e.NewValue);
            \_currentColor.Background = new SolidColorBrush((Color)e.NewValue);
            //RaiseEvent(new RoutedEventArgs(this.iCurrentColorChangedEvent, (Color)e.NewValue));
        }
    

    }

    I P 2 Replies Last reply
    0
    • S schiebel t

      Hello all, Im working on an ColorPicker user control and have problems registering DependencyPropertys. I try to register a new DependencyProperty in Visual Studio 2008 and all is working fine so far. Now i open Expression blend, add an reference to the ColorPicker.dll, and add a new instance to the window. When i now build the solution i get an exeption: "the property IsCurrentColor has allready been registerd from _ColorPicker" and the usercontrol cant anymore viewed in expression blend. Im a little confused because the application anyway started and all is working. Here is a little code of mine.

      public partial class _ColorPicker
      {
      private readonly DependencyProperty IsCurrentColorProperty;

          public \_ColorPicker()
      {
              this.InitializeComponent();            
      
                  IsCurrentColorProperty = DependencyProperty.Register(
                  "IsCurrentColor", typeof(Color), typeof(\_ColorPicker),
                  new FrameworkPropertyMetadata(Color.FromRgb(255, 255, 255),
                  new PropertyChangedCallback(OnIsCurrentColorChanged)));
          }
          private void OnIsCurrentColorChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
          {
              SetColorInfos((Color)e.NewValue);
              \_currentColor.Background = new SolidColorBrush((Color)e.NewValue);
              //RaiseEvent(new RoutedEventArgs(this.iCurrentColorChangedEvent, (Color)e.NewValue));
          }
      

      }

      I Offline
      I Offline
      Insincere Dave
      wrote on last edited by
      #2

      Dependency properties need to be static, you may want to download some snippets. There are some basic ones built in (Try propdp[TAB]) and a few others from different sources try http://drwpf.com/blog/Home/tabid/36/EntryId/22/Default.aspx.

      1 Reply Last reply
      0
      • S schiebel t

        Hello all, Im working on an ColorPicker user control and have problems registering DependencyPropertys. I try to register a new DependencyProperty in Visual Studio 2008 and all is working fine so far. Now i open Expression blend, add an reference to the ColorPicker.dll, and add a new instance to the window. When i now build the solution i get an exeption: "the property IsCurrentColor has allready been registerd from _ColorPicker" and the usercontrol cant anymore viewed in expression blend. Im a little confused because the application anyway started and all is working. Here is a little code of mine.

        public partial class _ColorPicker
        {
        private readonly DependencyProperty IsCurrentColorProperty;

            public \_ColorPicker()
        {
                this.InitializeComponent();            
        
                    IsCurrentColorProperty = DependencyProperty.Register(
                    "IsCurrentColor", typeof(Color), typeof(\_ColorPicker),
                    new FrameworkPropertyMetadata(Color.FromRgb(255, 255, 255),
                    new PropertyChangedCallback(OnIsCurrentColorChanged)));
            }
            private void OnIsCurrentColorChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
            {
                SetColorInfos((Color)e.NewValue);
                \_currentColor.Background = new SolidColorBrush((Color)e.NewValue);
                //RaiseEvent(new RoutedEventArgs(this.iCurrentColorChangedEvent, (Color)e.NewValue));
            }
        

        }

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        As Dave said - Dependency Properties need to be static. As well as Dr WPFs snippets, you may want to download MoXAML and install it in Visual Studio. One of the addin commands allows you to add boilerplate dependency properties just by filling in a dialog box. Follow my sig for the addin.

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        My blog | My articles | MoXAML PowerToys

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups