How can I create Custom Read-Only Dependency Properties?
Submitted by: AdministratorThe typical reason for specifying a read-only dependency property is that these are the properties that is used to determine the state, but where the state is defined in a multitude of factors. A typical example for a read-only property is IsMouseHover
This example shows how to 'register' an attached property as read-only. You can use dependency properties on any 'DependencyObject' types.
[C#]
public static readonly DependencyProperty IsBubbleSourceProperty = DependencyProperty.RegisterReadOnly(
"IsBubbleSource",
typeof(Boolean),
typeof(AquariumObject),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender)
);
Submitted by: Administrator
This example shows how to 'register' an attached property as read-only. You can use dependency properties on any 'DependencyObject' types.
[C#]
public static readonly DependencyProperty IsBubbleSourceProperty = DependencyProperty.RegisterReadOnly(
"IsBubbleSource",
typeof(Boolean),
typeof(AquariumObject),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender)
);
Submitted by: Administrator
Read Online WPF Job Interview Questions And Answers
Top WPF Questions
☺ | What is WPF? |
☺ | How can I mark the default value of a custom dependency property to be false? |
☺ | How can I enumerate all the descendants of a visual object? |
☺ | What is XAML extensible markup language? |
☺ | How can I create Custom Read-Only Dependency Properties? |
Top Application Program Categories
☺ | AutoCAD Interview Questions. |
☺ | Microsoft Office Interview Questions. |
☺ | Microsoft Outlook Interview Questions. |
☺ | Microsoft Excel Interview Questions. |
☺ | WPF Interview Questions. |