Windows Presentation Foundation (WPF) Question:

Download Job Interview Questions and Answers PDF

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

WPF Interview Question
WPF Interview Question

Answer:

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));
}

Download WPF Interview Questions And Answers PDF

Previous QuestionNext Question
How can I create Custom Read-Only Dependency Properties?How can I set an attached property in code?