Live Chat Icon For mobile
Live Chat Icon

How can I create Custom Read-Only Dependency Properties ?

Platform: WPF| Category: Dependency Property

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

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

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

Please submit your question and answer.