2,000 Things You Should Know About WPF

Everything a WPF Developer Needs to Know, in Bite-Sized Chunks

  • Home
  • About
  • Index
Posts Comments
  • Controls
  • Layout
  • Events
  • Basics
  • Blend
  • Graphics
  • XAML
  • Miscellaneous
  • Dependency Properties
  • Visual Studio

#575 – PropertyMetadata vs. FrameworkPropertyMetadata

June 7, 2012 1 Comment

When you implement a custom dependency property and you register the property by calling DependencyProperty.Register, you specify some metadata for the property by passing it an instance of PropertyMetadata.  This can be an instance of the PropertyMetadata class or an instance of one of its subclasses.  The differences are shown below.

PropertyMetadata – Basic metadata relating to dependency properties

  • CoerceValueCallback – coerce the value when being set
  • DefaultValue – a default value for the property
  • PropertyChangedCallback – respond to new effective value for the property

UIPropertyMetadata – derives from PropertyMetadata and adds:

  • IsAnimationProhibited – disable animations for this property?

FrameworkPropertyMetadata – derives from UIPropertyMetadata and adds:

  • AffectsArrange, AffectsMeasure, AffectsParentArrange, AffectsParentMeasure, AffectsRender – Should layout calculations be re-run after property value changes?
  • BindsTwoWayByDefault, DefaultUpdateSourceTrigger, IsDataBindingAllowed, IsNotDataBindable – Dictates how property participates in data binding
  • Inherits, OverridesInheritanceBehavior – Does inheritance work for this property?
  • Journal – Store this value when journaling?
  • SubPropertiesDoNotAffectRender – Check properties of this object when layout changes?

Filed under Dependency Properties Tagged with Dependency Properties, FrameworkPropertyMetadata, PropertyMetadata, WPF

#162 – UIPropertyMetadata and FrameworkPropertyMetadata

December 21, 2010 Leave a comment

Some dependency properties in WPF have metadata deriving from UIPropertyMetadata or FrameworkPropertyMetadata, rather than from PropertyMetadata.

For example, the ComboBox.IsEnabledProperty, which is defined in UIElement has metadata of type UIPropertyMetadata.

            UIPropertyMetadata meta = (UIPropertyMetadata)ComboBox.IsEnabledProperty.GetMetadata(cboTest);

UIPropertyMetadata derives from PropertyMetadata and adds the IsAnimationProhibited property.

The Button.IsEnabledProperty has metadata of type FrameworkPropertyMetadata.

            FrameworkPropertyMetadata meta = (FrameworkPropertyMetadata)Button.IsEnabledProperty.GetMetadata(btnTest);

FrameworkPropertyMetadata derives from UIPropertyMetadata and adds properties related to layout.

Filed under Dependency Properties Tagged with FrameworkPropertyMetadata, PropertyMetadata, UIPropertyMetadata, WPF

Sean Sexton

Recent Posts

  • #1,219 – Expanding All Nodes in a TreeView by Default
  • #1,218 – Stretching Items in TreeView across Entire Control
  • #1,217 – Using Multiple HierarchicalDataTemplates in a TreeView
  • #1,216 – Creating a Custom ItemTemplate in a TreeView
  • #1,215 – Binding a TreeView to a Hierarchical Data Source

Blogroll

  • 2,000 Things You Should Know About C#
  • Britannica Geek
  • Sean on Twitter
  • Sean's Stuff

Calendar

June 2022
S M T W T F S
 1234
567891011
12131415161718
19202122232425
2627282930  
« Sep    

Top Posts

  • #986 - Filtering a ListBox Using a CollectionViewSource
  • Index
  • #197 - Override Application Class Methods for Standard Events
  • #825 - Two Way Binding for a CheckBox
  • #1,024 - Making a Slider Cycle through Values of an Enumerated Type
  • #1,011 - ComboBox Data Binding Basics, Part III
  • #152 - Use ReadLocalValue() to Find the Local Value of a Dependency Property
  • #1,060 - Clipping in Grid Happens Before Render Transforms
  • #821 - Use TextFormattingMode to Make Text Look More Clear
  • #1,111 - Referencing Content Files from XAML

Tags

Application Background Basics Binding Blend Border Brush Button Calendar Canvas CheckBox Color Colors ComboBox Commands ContentControl Controls Cursor Data Binding Dependency Properties Dependency property DockPanel Drag-and-Drop Events Expander FlowDocument Focus Fonts FrameworkElement Gradient Graphics Grid GridSplitter GroupBox HorizontalAlignment Image InkCanvas Input ItemsControl Keyboard Keyboard Focus KeyDown KeyUp Layout LinearGradientBrush ListBox Localization Manipulation Margin Measure Miscellaneous Mouse Panel Popup Radial Gradient Resources Routed Events ScrollViewer Shape Slider StackPanel TabControl Text TextBlock TextBox Tooltip Touch Input Transforms UIElement Visual Studio Window Windows WPF WrapPanel XAML

Blog Stats

  • 5,007,866 hits

Blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Follow Following
    • 2,000 Things You Should Know About WPF
    • Join 488 other followers
    • Already have a WordPress.com account? Log in now.
    • 2,000 Things You Should Know About WPF
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...