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. WPF Dependancy Property issue

WPF Dependancy Property issue

Scheduled Pinned Locked Moved WPF
csharpwpfhelpquestion
5 Posts 4 Posters 12 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.
  • R Offline
    R Offline
    riddle2000
    wrote on last edited by
    #1

    Hi. I have a class library with a class that requires a dependanct property to be included. So I've referenced WindowsBase and inserted Using System.Window. I've used the following code to set up the dependancy property: public bool IsChecked { get { return (bool)GetValue(IsCheckedProperty); } set { SetValue(IsCheckedProperty, value); } } public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register("IsChecked", typeof(bool), typeof(EdgeProperty), new UIPropertyMetadata(false)); I can see that the DependencyProperty class is referenced and all is fine. However, the methods 'GetValue' and 'SetValue' do not exist. I know these are from the DependancyObject class, which is referenced. Anybody know what's going on? Cheers, Chris

    P L I 3 Replies Last reply
    0
    • R riddle2000

      Hi. I have a class library with a class that requires a dependanct property to be included. So I've referenced WindowsBase and inserted Using System.Window. I've used the following code to set up the dependancy property: public bool IsChecked { get { return (bool)GetValue(IsCheckedProperty); } set { SetValue(IsCheckedProperty, value); } } public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register("IsChecked", typeof(bool), typeof(EdgeProperty), new UIPropertyMetadata(false)); I can see that the DependencyProperty class is referenced and all is fine. However, the methods 'GetValue' and 'SetValue' do not exist. I know these are from the DependancyObject class, which is referenced. Anybody know what's going on? Cheers, Chris

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

      What does your class inherit from?

      Deja View - the feeling that you've seen this post before.

      My blog | My articles

      1 Reply Last reply
      0
      • R riddle2000

        Hi. I have a class library with a class that requires a dependanct property to be included. So I've referenced WindowsBase and inserted Using System.Window. I've used the following code to set up the dependancy property: public bool IsChecked { get { return (bool)GetValue(IsCheckedProperty); } set { SetValue(IsCheckedProperty, value); } } public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register("IsChecked", typeof(bool), typeof(EdgeProperty), new UIPropertyMetadata(false)); I can see that the DependencyProperty class is referenced and all is fine. However, the methods 'GetValue' and 'SetValue' do not exist. I know these are from the DependancyObject class, which is referenced. Anybody know what's going on? Cheers, Chris

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Chris, Using Visual Studio, add a new project to your solution, a WPF Custom Control library. After you create it, you can delete the Themes folder and the custom control it creates by default. Now move your class into this project and everything will work fine.

        Cheers, Karl » CodeProject 2008 MVP » Microsoft MVP - Client App Dev My Blog | Mole's Home Page | MVP Profile

        Just a grain of sand on the worlds beaches.

        1 Reply Last reply
        0
        • R riddle2000

          Hi. I have a class library with a class that requires a dependanct property to be included. So I've referenced WindowsBase and inserted Using System.Window. I've used the following code to set up the dependancy property: public bool IsChecked { get { return (bool)GetValue(IsCheckedProperty); } set { SetValue(IsCheckedProperty, value); } } public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register("IsChecked", typeof(bool), typeof(EdgeProperty), new UIPropertyMetadata(false)); I can see that the DependencyProperty class is referenced and all is fine. However, the methods 'GetValue' and 'SetValue' do not exist. I know these are from the DependancyObject class, which is referenced. Anybody know what's going on? Cheers, Chris

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

          You need to inherit from DependencyObject not just reference it.

          R 1 Reply Last reply
          0
          • I Insincere Dave

            You need to inherit from DependencyObject not just reference it.

            R Offline
            R Offline
            riddle2000
            wrote on last edited by
            #5

            Cheers guys, that worked.

            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