Live Chat Icon For mobile
Live Chat Icon

How can I mark the default value of a custom dependency property to be false?

Platform: WPF| Category: Dependency Property

Here is an example :

[C#]
 
public class MyStateControl : ButtonBase
{
  public MyStateControl() : base() { }
  public Boolean State
  {
    get { return (Boolean)this.GetValue(StateProperty); }
    set { this.SetValue(StateProperty, value); } 
  }
  public static readonly DependencyProperty StateProperty = DependencyProperty.Register(
    'State', typeof(Boolean), typeof(MyStateControl),new PropertyMetadata(false));
}

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.