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

#163 – Constructing FrameworkPropertyMetadata

December 22, 2010 Leave a comment

When you look at the metadata for a dependency property that is storing its metadata as an instance of FrameworkPropertyMetadata, you’ll see a series of boolean properties.

As a convenience, when constructing an instance of FrameworkPropertyMetadata, you don’t have to pass all of these boolean values into the constructor individually.  Instead, the constructor accepts a flags parameter that is a logical OR of a series of enumeration values.  The individual enumeration values come from the FrameworkPropertyMetadataOptions enum.

        // Register ZHeightProperty dependency property
        private static FrameworkPropertyMetadata meta = new FrameworkPropertyMetadata(1,   // default = 1
            FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure |
            FrameworkPropertyMetadataOptions.AffectsParentArrange | FrameworkPropertyMetadataOptions.AffectsParentMeasure |
            FrameworkPropertyMetadataOptions.BindsTwoWayByDefault);

        public static readonly DependencyProperty ZHeightProperty =
            DependencyProperty.Register("ZHeightProperty", typeof(int), typeof(ThreeDButton), meta);
Advertisement

Filed under Dependency Properties Tagged with Dependency Properties, FrameworkPropertyMetadata, Metadata, 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

December 2010
S M T W T F S
 1234
567891011
12131415161718
19202122232425
262728293031  
« Nov   Jan »

Top Posts

  • #220 - Using the Predefined Colors
  • #351 - Binding a CheckBox's IsChecked Property to a Boolean Variable
  • Index
  • #1,204 - Using a DataTrigger to Change Content in a ContentPresenter
  • #1,107 - Accessing an Embedded Resource Using a Uri
  • #1,218 - Stretching Items in TreeView across Entire Control
  • #1,012 - Using a Different Data Template for the Face of a ComboBox
  • #1,217 - Using Multiple HierarchicalDataTemplates in a TreeView
  • #400 - Using a WrapPanel as the Items Panel for a ListBox
  • #854 - Clicked vs. Checked/Unchecked Events for CheckBox

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,176,060 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 290 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...