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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WPF
  4. How Do I Declare a New Property for a UserControl?

How Do I Declare a New Property for a UserControl?

Scheduled Pinned Locked Moved WPF
csharpquestionwpf
2 Posts 2 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.
  • T Offline
    T Offline
    That Asian Guy
    wrote on last edited by
    #1

    I tried it the traditional C# way of:

    public String test
    {
    get
    {
    return "hi";
    }
    set
    {
    button1.Content = value;
    }
    }

    But the WPF designer didn't seem to be able to detect it, although I could still do it programatically. What's the proper way of declaring a new property for a control? Thanks.

    A 1 Reply Last reply
    0
    • T That Asian Guy

      I tried it the traditional C# way of:

      public String test
      {
      get
      {
      return "hi";
      }
      set
      {
      button1.Content = value;
      }
      }

      But the WPF designer didn't seem to be able to detect it, although I could still do it programatically. What's the proper way of declaring a new property for a control? Thanks.

      A Offline
      A Offline
      ABitSmart
      wrote on last edited by
      #2

      That Asian Guy wrote:

      WPF designer didn't seem to be able to detect it

      It does show up in XAML. What exactly are you referring to ?

      That Asian Guy wrote:

      What's the proper way of declaring a new property for a control?

      If you want it to take part in binding(as a target specifically),styles,animations etc. you might want to implement it as a DependencyProperty[^]

      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