What are the differences among PropertyMetaData, UIPropertyMetadata, and FrameworkMetaData in WPFWhat is the correct way to create a single-instance WPF application?Interview questions: WPF DeveloperHow do I use WPF bindings with RelativeSource?What's the difference between StaticResource and DynamicResource in WPF?In WPF, what are the differences between the x:Name and Name attributes?When should I use FrameworkPropertyMetadata or UIPropertyMetadata over plain PropertyMetadata?Difference between SelectedItem, SelectedValue and SelectedValuePathWPF: switching UserControls depending on corresponding ViewModels (MVVM)wpf animation and indirect targeting: Cannot resolve all property referencesWhat is the difference between x:Reference and ElementName?
What's the difference between a share and a stock?
Was "The Hobbit" ever abridged?
If magnetic force can't do any work, then how can we define a potential?
Dissuading my girlfriend from a scam
Is mathematics truth?
Is using different public keys for different peers safer than reusing the public key, beyond forward secrecy - x25519
Do I have to rename all creatures in a new world?
Who are these people in this satirical cartoon of the Congress of Verona?
Was Rosie the Riveter sourced from a Michelangelo painting?
Round away from zero
What would a biological creature need in order to see into the future?
Left my gmail logged in when I was fired
Bidirectional Dictionary
Can anyone find an image of Henry Bolingbroke's Sovereygne Feather Seal?
MOSFET broke after attaching capacitor bank
If I sell my PS4 game disc and buy a digital version, can I still access my saved game?
Is the Levitate spell supposed to basically disable a melee-based enemy?
Why do we need explainable AI?
Low quality postdoc application and deadline extension
Is it rude to ask my opponent to resign an online game when they have a lost endgame?
Vimscript - Surround word under cursor with quotes
How can I oppose my advisor granting gift authorship to a collaborator?
Why is に used with this verb?
What's this constructed number's starter?
What are the differences among PropertyMetaData, UIPropertyMetadata, and FrameworkMetaData in WPF
What is the correct way to create a single-instance WPF application?Interview questions: WPF DeveloperHow do I use WPF bindings with RelativeSource?What's the difference between StaticResource and DynamicResource in WPF?In WPF, what are the differences between the x:Name and Name attributes?When should I use FrameworkPropertyMetadata or UIPropertyMetadata over plain PropertyMetadata?Difference between SelectedItem, SelectedValue and SelectedValuePathWPF: switching UserControls depending on corresponding ViewModels (MVVM)wpf animation and indirect targeting: Cannot resolve all property referencesWhat is the difference between x:Reference and ElementName?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I know the basic difference among these classes that PropertyMetadata is used when we backup property, UIPropertyMetadata when we want to have support for animation, and FrameworkMetadata for Framework properties to be used in user controls.
But I understand theoretical part only.
It will be a great hep if you please explain a simplest example that uses all these 3 classes in 3 different dependency properties distinguishing them clearly.
Thanks in advance.
wpf
add a comment |
I know the basic difference among these classes that PropertyMetadata is used when we backup property, UIPropertyMetadata when we want to have support for animation, and FrameworkMetadata for Framework properties to be used in user controls.
But I understand theoretical part only.
It will be a great hep if you please explain a simplest example that uses all these 3 classes in 3 different dependency properties distinguishing them clearly.
Thanks in advance.
wpf
You could easily create 3 dependency properties yourself and observe the results. Then if you still have a specific problem, come and ask a question.
– Benjamin Gale
Jan 8 '13 at 18:29
I have just started playing with Dependency properties. But to get acquainted with all these 3 classes I am seeking a simple example, if you write and explain, it will very helpful for me. Thanks.
– WpfBee
Jan 8 '13 at 18:35
1
wpf.2000things.com/2012/06/07/…
– eran otzap
Feb 10 '15 at 7:34
add a comment |
I know the basic difference among these classes that PropertyMetadata is used when we backup property, UIPropertyMetadata when we want to have support for animation, and FrameworkMetadata for Framework properties to be used in user controls.
But I understand theoretical part only.
It will be a great hep if you please explain a simplest example that uses all these 3 classes in 3 different dependency properties distinguishing them clearly.
Thanks in advance.
wpf
I know the basic difference among these classes that PropertyMetadata is used when we backup property, UIPropertyMetadata when we want to have support for animation, and FrameworkMetadata for Framework properties to be used in user controls.
But I understand theoretical part only.
It will be a great hep if you please explain a simplest example that uses all these 3 classes in 3 different dependency properties distinguishing them clearly.
Thanks in advance.
wpf
wpf
asked Jan 8 '13 at 18:27
WpfBeeWpfBee
8974 gold badges16 silver badges22 bronze badges
8974 gold badges16 silver badges22 bronze badges
You could easily create 3 dependency properties yourself and observe the results. Then if you still have a specific problem, come and ask a question.
– Benjamin Gale
Jan 8 '13 at 18:29
I have just started playing with Dependency properties. But to get acquainted with all these 3 classes I am seeking a simple example, if you write and explain, it will very helpful for me. Thanks.
– WpfBee
Jan 8 '13 at 18:35
1
wpf.2000things.com/2012/06/07/…
– eran otzap
Feb 10 '15 at 7:34
add a comment |
You could easily create 3 dependency properties yourself and observe the results. Then if you still have a specific problem, come and ask a question.
– Benjamin Gale
Jan 8 '13 at 18:29
I have just started playing with Dependency properties. But to get acquainted with all these 3 classes I am seeking a simple example, if you write and explain, it will very helpful for me. Thanks.
– WpfBee
Jan 8 '13 at 18:35
1
wpf.2000things.com/2012/06/07/…
– eran otzap
Feb 10 '15 at 7:34
You could easily create 3 dependency properties yourself and observe the results. Then if you still have a specific problem, come and ask a question.
– Benjamin Gale
Jan 8 '13 at 18:29
You could easily create 3 dependency properties yourself and observe the results. Then if you still have a specific problem, come and ask a question.
– Benjamin Gale
Jan 8 '13 at 18:29
I have just started playing with Dependency properties. But to get acquainted with all these 3 classes I am seeking a simple example, if you write and explain, it will very helpful for me. Thanks.
– WpfBee
Jan 8 '13 at 18:35
I have just started playing with Dependency properties. But to get acquainted with all these 3 classes I am seeking a simple example, if you write and explain, it will very helpful for me. Thanks.
– WpfBee
Jan 8 '13 at 18:35
1
1
wpf.2000things.com/2012/06/07/…
– eran otzap
Feb 10 '15 at 7:34
wpf.2000things.com/2012/06/07/…
– eran otzap
Feb 10 '15 at 7:34
add a comment |
3 Answers
3
active
oldest
votes
Source: PropertyMetadata vs. FrameworkPropertyMetadata
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 ofPropertyMetadata
. This can be an instance of thePropertyMetadata
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 fromPropertyMetadata
and adds:
IsAnimationProhibited
– disable animations for this property?
FrameworkPropertyMetadata
– derives fromUIPropertyMetadata
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?
add a comment |
An important practical difference between PropertyMetadata and FrameworkPropertyMetadata is that the latter allows to specify a set of FrameworkPropertyMetadataOptions.
For example, specifying FrameworkPropertyMetadataOptions.AffectsRender
cares for initiating a re-rendering of a UIElement on which the property has changed. Without this flag you would have to do that manually in a PropertyChangedCallback.
add a comment |
All of the behaviors exposed by FrameworkPropertyMetadata
and UIPropertyMetadata
are controlled by flag bits that are recorded in a single enum
(32-bit uint
) field called _flags
which is declared in the PropertyMetadata
base class, even though none of the flags are actually publicly exposed from there. Here is the declaration of that enum
:
internal enum MetadataFlags : uint
DefaultValueModifiedID /**/= 0b_00000000_00000000_00000000_00000001, //0x00000001
SealedID /**/= 0b_00000000_00000000_00000000_00000010, //0x00000002
Inherited /**/= 0b_00000000_00000000_00000000_00010000, //0x00000010
UI_IsAnimationProhibitedID /**/= 0b_00000000_00000000_00000000_00100000, //0x00000020
FW_AffectsMeasureID /**/= 0b_00000000_00000000_00000000_01000000, //0x00000040
FW_AffectsArrangeID /**/= 0b_00000000_00000000_00000000_10000000, //0x00000080
FW_AffectsParentMeasureID /**/= 0b_00000000_00000000_00000001_00000000, //0x00000100
FW_AffectsParentArrangeID /**/= 0b_00000000_00000000_00000010_00000000, //0x00000200
FW_AffectsRenderID /**/= 0b_00000000_00000000_00000100_00000000, //0x00000400
FW_OverridesInheritanceBehaviorID /**/= 0b_00000000_00000000_00001000_00000000, //0x00000800
FW_IsNotDataBindableID /**/= 0b_00000000_00000000_00010000_00000000, //0x00001000
FW_BindsTwoWayByDefaultID /**/= 0b_00000000_00000000_00100000_00000000, //0x00002000
FW_ShouldBeJournaledID /**/= 0b_00000000_00000000_01000000_00000000, //0x00004000
FW_SubPropertiesDoNotAffectRenderID /**/= 0b_00000000_00000000_10000000_00000000, //0x00008000
FW_SubPropertiesDoNotAffectRenderModifiedID= 0b_00000000_00000001_00000000_00000000, //0x00010000
FW_InheritsModifiedID /**/= 0b_00000000_00010000_00000000_00000000, //0x00100000
FW_OverridesInheritanceBehaviorModifiedID = 0b_00000000_00100000_00000000_00000000, //0x00200000
FW_ShouldBeJournaledModifiedID /**/= 0b_00000001_00000000_00000000_00000000, //0x01000000
FW_UpdatesSourceOnLostFocusByDefaultID /**/= 0b_00000010_00000000_00000000_00000000, //0x02000000
FW_DefaultUpdateSourceTriggerModifiedID/**/= 0b_00000100_00000000_00000000_00000000, //0x04000000
FW_ReadOnlyID /**/= 0b_00001000_00000000_00000000_00000000, //0x08000000
FW_DefaultUpdateSourceTriggerEnumBit1 /**/= 0b_01000000_00000000_00000000_00000000, //0x40000000
FW_DefaultUpdateSourceTriggerEnumBit2 /**/= 0b_10000000_00000000_00000000_00000000, //0x80000000
;
Note also how the following three properties, all declared by FrameworkPropertyMetadata
, interact. To wit, IsDataBindingAllowed
is not the same as !IsNotDataBindable
; the former adds the additional restriction of ruling out the use of the incorrect binding direction for 'read-only' properties.
private bool ReadOnly => (_flags & FW_ReadOnlyID) != 0;
public bool IsDataBindingAllowed =>
(_flags & FW_IsNotDataBindableID) == 0 && !this.ReadOnly;
public bool IsNotDataBindable => (_flags & FW_IsNotDataBindableID) != 0;
[edit:] ALERT/WARNING: For some unknown reason, the flags shown above do not share the same values as those specified by the corresponding
FrameworkPropertyMetadataOptions
flag![Flags]
public enum FrameworkPropertyMetadataOptions
// FPMO MetadataFlags
// ---------- ----------
// 0x00000010 ←┐
None /**/ = 0x00000000, // │
AffectsMeasure /**/ = 0x00000001, // << 6 0x00000040 │
AffectsArrange /**/ = 0x00000002, // << 6 0x00000080 │
AffectsParentMeasure /**/ = 0x00000004, // << 6 0x00000100 │
AffectsParentArrange /**/ = 0x00000008, // << 6 0x00000200 │
AffectsRender /**/ = 0x00000010, // << 6 0x00000400 │
Inherits /**/ = 0x00000020, // >> 1 → → ────┘
OverridesInheritanceBehavior /**/ = 0x00000040, // << 5 0x00000800
NotDataBindable /**/ = 0x00000080, // << 5 0x00001000
BindsTwoWayByDefault /**/ = 0x00000100, // << 5 0x00002000
Journal /**/ = 0x00000400, // << 4 0x00004000
SubPropertiesDoNotAffectRender /**/ = 0x00000800, // << 4 0x00008000
;
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14221636%2fwhat-are-the-differences-among-propertymetadata-uipropertymetadata-and-framewo%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Source: PropertyMetadata vs. FrameworkPropertyMetadata
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 ofPropertyMetadata
. This can be an instance of thePropertyMetadata
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 fromPropertyMetadata
and adds:
IsAnimationProhibited
– disable animations for this property?
FrameworkPropertyMetadata
– derives fromUIPropertyMetadata
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?
add a comment |
Source: PropertyMetadata vs. FrameworkPropertyMetadata
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 ofPropertyMetadata
. This can be an instance of thePropertyMetadata
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 fromPropertyMetadata
and adds:
IsAnimationProhibited
– disable animations for this property?
FrameworkPropertyMetadata
– derives fromUIPropertyMetadata
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?
add a comment |
Source: PropertyMetadata vs. FrameworkPropertyMetadata
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 ofPropertyMetadata
. This can be an instance of thePropertyMetadata
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 fromPropertyMetadata
and adds:
IsAnimationProhibited
– disable animations for this property?
FrameworkPropertyMetadata
– derives fromUIPropertyMetadata
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?
Source: PropertyMetadata vs. FrameworkPropertyMetadata
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 ofPropertyMetadata
. This can be an instance of thePropertyMetadata
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 fromPropertyMetadata
and adds:
IsAnimationProhibited
– disable animations for this property?
FrameworkPropertyMetadata
– derives fromUIPropertyMetadata
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?
edited Feb 9 '16 at 22:38
Joshua Shearer
1,08311 silver badges22 bronze badges
1,08311 silver badges22 bronze badges
answered May 18 '15 at 18:13
MuthuganeshMuthuganesh
1211 silver badge2 bronze badges
1211 silver badge2 bronze badges
add a comment |
add a comment |
An important practical difference between PropertyMetadata and FrameworkPropertyMetadata is that the latter allows to specify a set of FrameworkPropertyMetadataOptions.
For example, specifying FrameworkPropertyMetadataOptions.AffectsRender
cares for initiating a re-rendering of a UIElement on which the property has changed. Without this flag you would have to do that manually in a PropertyChangedCallback.
add a comment |
An important practical difference between PropertyMetadata and FrameworkPropertyMetadata is that the latter allows to specify a set of FrameworkPropertyMetadataOptions.
For example, specifying FrameworkPropertyMetadataOptions.AffectsRender
cares for initiating a re-rendering of a UIElement on which the property has changed. Without this flag you would have to do that manually in a PropertyChangedCallback.
add a comment |
An important practical difference between PropertyMetadata and FrameworkPropertyMetadata is that the latter allows to specify a set of FrameworkPropertyMetadataOptions.
For example, specifying FrameworkPropertyMetadataOptions.AffectsRender
cares for initiating a re-rendering of a UIElement on which the property has changed. Without this flag you would have to do that manually in a PropertyChangedCallback.
An important practical difference between PropertyMetadata and FrameworkPropertyMetadata is that the latter allows to specify a set of FrameworkPropertyMetadataOptions.
For example, specifying FrameworkPropertyMetadataOptions.AffectsRender
cares for initiating a re-rendering of a UIElement on which the property has changed. Without this flag you would have to do that manually in a PropertyChangedCallback.
answered Jan 8 '13 at 19:33
ClemensClemens
94.1k8 gold badges100 silver badges196 bronze badges
94.1k8 gold badges100 silver badges196 bronze badges
add a comment |
add a comment |
All of the behaviors exposed by FrameworkPropertyMetadata
and UIPropertyMetadata
are controlled by flag bits that are recorded in a single enum
(32-bit uint
) field called _flags
which is declared in the PropertyMetadata
base class, even though none of the flags are actually publicly exposed from there. Here is the declaration of that enum
:
internal enum MetadataFlags : uint
DefaultValueModifiedID /**/= 0b_00000000_00000000_00000000_00000001, //0x00000001
SealedID /**/= 0b_00000000_00000000_00000000_00000010, //0x00000002
Inherited /**/= 0b_00000000_00000000_00000000_00010000, //0x00000010
UI_IsAnimationProhibitedID /**/= 0b_00000000_00000000_00000000_00100000, //0x00000020
FW_AffectsMeasureID /**/= 0b_00000000_00000000_00000000_01000000, //0x00000040
FW_AffectsArrangeID /**/= 0b_00000000_00000000_00000000_10000000, //0x00000080
FW_AffectsParentMeasureID /**/= 0b_00000000_00000000_00000001_00000000, //0x00000100
FW_AffectsParentArrangeID /**/= 0b_00000000_00000000_00000010_00000000, //0x00000200
FW_AffectsRenderID /**/= 0b_00000000_00000000_00000100_00000000, //0x00000400
FW_OverridesInheritanceBehaviorID /**/= 0b_00000000_00000000_00001000_00000000, //0x00000800
FW_IsNotDataBindableID /**/= 0b_00000000_00000000_00010000_00000000, //0x00001000
FW_BindsTwoWayByDefaultID /**/= 0b_00000000_00000000_00100000_00000000, //0x00002000
FW_ShouldBeJournaledID /**/= 0b_00000000_00000000_01000000_00000000, //0x00004000
FW_SubPropertiesDoNotAffectRenderID /**/= 0b_00000000_00000000_10000000_00000000, //0x00008000
FW_SubPropertiesDoNotAffectRenderModifiedID= 0b_00000000_00000001_00000000_00000000, //0x00010000
FW_InheritsModifiedID /**/= 0b_00000000_00010000_00000000_00000000, //0x00100000
FW_OverridesInheritanceBehaviorModifiedID = 0b_00000000_00100000_00000000_00000000, //0x00200000
FW_ShouldBeJournaledModifiedID /**/= 0b_00000001_00000000_00000000_00000000, //0x01000000
FW_UpdatesSourceOnLostFocusByDefaultID /**/= 0b_00000010_00000000_00000000_00000000, //0x02000000
FW_DefaultUpdateSourceTriggerModifiedID/**/= 0b_00000100_00000000_00000000_00000000, //0x04000000
FW_ReadOnlyID /**/= 0b_00001000_00000000_00000000_00000000, //0x08000000
FW_DefaultUpdateSourceTriggerEnumBit1 /**/= 0b_01000000_00000000_00000000_00000000, //0x40000000
FW_DefaultUpdateSourceTriggerEnumBit2 /**/= 0b_10000000_00000000_00000000_00000000, //0x80000000
;
Note also how the following three properties, all declared by FrameworkPropertyMetadata
, interact. To wit, IsDataBindingAllowed
is not the same as !IsNotDataBindable
; the former adds the additional restriction of ruling out the use of the incorrect binding direction for 'read-only' properties.
private bool ReadOnly => (_flags & FW_ReadOnlyID) != 0;
public bool IsDataBindingAllowed =>
(_flags & FW_IsNotDataBindableID) == 0 && !this.ReadOnly;
public bool IsNotDataBindable => (_flags & FW_IsNotDataBindableID) != 0;
[edit:] ALERT/WARNING: For some unknown reason, the flags shown above do not share the same values as those specified by the corresponding
FrameworkPropertyMetadataOptions
flag![Flags]
public enum FrameworkPropertyMetadataOptions
// FPMO MetadataFlags
// ---------- ----------
// 0x00000010 ←┐
None /**/ = 0x00000000, // │
AffectsMeasure /**/ = 0x00000001, // << 6 0x00000040 │
AffectsArrange /**/ = 0x00000002, // << 6 0x00000080 │
AffectsParentMeasure /**/ = 0x00000004, // << 6 0x00000100 │
AffectsParentArrange /**/ = 0x00000008, // << 6 0x00000200 │
AffectsRender /**/ = 0x00000010, // << 6 0x00000400 │
Inherits /**/ = 0x00000020, // >> 1 → → ────┘
OverridesInheritanceBehavior /**/ = 0x00000040, // << 5 0x00000800
NotDataBindable /**/ = 0x00000080, // << 5 0x00001000
BindsTwoWayByDefault /**/ = 0x00000100, // << 5 0x00002000
Journal /**/ = 0x00000400, // << 4 0x00004000
SubPropertiesDoNotAffectRender /**/ = 0x00000800, // << 4 0x00008000
;
add a comment |
All of the behaviors exposed by FrameworkPropertyMetadata
and UIPropertyMetadata
are controlled by flag bits that are recorded in a single enum
(32-bit uint
) field called _flags
which is declared in the PropertyMetadata
base class, even though none of the flags are actually publicly exposed from there. Here is the declaration of that enum
:
internal enum MetadataFlags : uint
DefaultValueModifiedID /**/= 0b_00000000_00000000_00000000_00000001, //0x00000001
SealedID /**/= 0b_00000000_00000000_00000000_00000010, //0x00000002
Inherited /**/= 0b_00000000_00000000_00000000_00010000, //0x00000010
UI_IsAnimationProhibitedID /**/= 0b_00000000_00000000_00000000_00100000, //0x00000020
FW_AffectsMeasureID /**/= 0b_00000000_00000000_00000000_01000000, //0x00000040
FW_AffectsArrangeID /**/= 0b_00000000_00000000_00000000_10000000, //0x00000080
FW_AffectsParentMeasureID /**/= 0b_00000000_00000000_00000001_00000000, //0x00000100
FW_AffectsParentArrangeID /**/= 0b_00000000_00000000_00000010_00000000, //0x00000200
FW_AffectsRenderID /**/= 0b_00000000_00000000_00000100_00000000, //0x00000400
FW_OverridesInheritanceBehaviorID /**/= 0b_00000000_00000000_00001000_00000000, //0x00000800
FW_IsNotDataBindableID /**/= 0b_00000000_00000000_00010000_00000000, //0x00001000
FW_BindsTwoWayByDefaultID /**/= 0b_00000000_00000000_00100000_00000000, //0x00002000
FW_ShouldBeJournaledID /**/= 0b_00000000_00000000_01000000_00000000, //0x00004000
FW_SubPropertiesDoNotAffectRenderID /**/= 0b_00000000_00000000_10000000_00000000, //0x00008000
FW_SubPropertiesDoNotAffectRenderModifiedID= 0b_00000000_00000001_00000000_00000000, //0x00010000
FW_InheritsModifiedID /**/= 0b_00000000_00010000_00000000_00000000, //0x00100000
FW_OverridesInheritanceBehaviorModifiedID = 0b_00000000_00100000_00000000_00000000, //0x00200000
FW_ShouldBeJournaledModifiedID /**/= 0b_00000001_00000000_00000000_00000000, //0x01000000
FW_UpdatesSourceOnLostFocusByDefaultID /**/= 0b_00000010_00000000_00000000_00000000, //0x02000000
FW_DefaultUpdateSourceTriggerModifiedID/**/= 0b_00000100_00000000_00000000_00000000, //0x04000000
FW_ReadOnlyID /**/= 0b_00001000_00000000_00000000_00000000, //0x08000000
FW_DefaultUpdateSourceTriggerEnumBit1 /**/= 0b_01000000_00000000_00000000_00000000, //0x40000000
FW_DefaultUpdateSourceTriggerEnumBit2 /**/= 0b_10000000_00000000_00000000_00000000, //0x80000000
;
Note also how the following three properties, all declared by FrameworkPropertyMetadata
, interact. To wit, IsDataBindingAllowed
is not the same as !IsNotDataBindable
; the former adds the additional restriction of ruling out the use of the incorrect binding direction for 'read-only' properties.
private bool ReadOnly => (_flags & FW_ReadOnlyID) != 0;
public bool IsDataBindingAllowed =>
(_flags & FW_IsNotDataBindableID) == 0 && !this.ReadOnly;
public bool IsNotDataBindable => (_flags & FW_IsNotDataBindableID) != 0;
[edit:] ALERT/WARNING: For some unknown reason, the flags shown above do not share the same values as those specified by the corresponding
FrameworkPropertyMetadataOptions
flag![Flags]
public enum FrameworkPropertyMetadataOptions
// FPMO MetadataFlags
// ---------- ----------
// 0x00000010 ←┐
None /**/ = 0x00000000, // │
AffectsMeasure /**/ = 0x00000001, // << 6 0x00000040 │
AffectsArrange /**/ = 0x00000002, // << 6 0x00000080 │
AffectsParentMeasure /**/ = 0x00000004, // << 6 0x00000100 │
AffectsParentArrange /**/ = 0x00000008, // << 6 0x00000200 │
AffectsRender /**/ = 0x00000010, // << 6 0x00000400 │
Inherits /**/ = 0x00000020, // >> 1 → → ────┘
OverridesInheritanceBehavior /**/ = 0x00000040, // << 5 0x00000800
NotDataBindable /**/ = 0x00000080, // << 5 0x00001000
BindsTwoWayByDefault /**/ = 0x00000100, // << 5 0x00002000
Journal /**/ = 0x00000400, // << 4 0x00004000
SubPropertiesDoNotAffectRender /**/ = 0x00000800, // << 4 0x00008000
;
add a comment |
All of the behaviors exposed by FrameworkPropertyMetadata
and UIPropertyMetadata
are controlled by flag bits that are recorded in a single enum
(32-bit uint
) field called _flags
which is declared in the PropertyMetadata
base class, even though none of the flags are actually publicly exposed from there. Here is the declaration of that enum
:
internal enum MetadataFlags : uint
DefaultValueModifiedID /**/= 0b_00000000_00000000_00000000_00000001, //0x00000001
SealedID /**/= 0b_00000000_00000000_00000000_00000010, //0x00000002
Inherited /**/= 0b_00000000_00000000_00000000_00010000, //0x00000010
UI_IsAnimationProhibitedID /**/= 0b_00000000_00000000_00000000_00100000, //0x00000020
FW_AffectsMeasureID /**/= 0b_00000000_00000000_00000000_01000000, //0x00000040
FW_AffectsArrangeID /**/= 0b_00000000_00000000_00000000_10000000, //0x00000080
FW_AffectsParentMeasureID /**/= 0b_00000000_00000000_00000001_00000000, //0x00000100
FW_AffectsParentArrangeID /**/= 0b_00000000_00000000_00000010_00000000, //0x00000200
FW_AffectsRenderID /**/= 0b_00000000_00000000_00000100_00000000, //0x00000400
FW_OverridesInheritanceBehaviorID /**/= 0b_00000000_00000000_00001000_00000000, //0x00000800
FW_IsNotDataBindableID /**/= 0b_00000000_00000000_00010000_00000000, //0x00001000
FW_BindsTwoWayByDefaultID /**/= 0b_00000000_00000000_00100000_00000000, //0x00002000
FW_ShouldBeJournaledID /**/= 0b_00000000_00000000_01000000_00000000, //0x00004000
FW_SubPropertiesDoNotAffectRenderID /**/= 0b_00000000_00000000_10000000_00000000, //0x00008000
FW_SubPropertiesDoNotAffectRenderModifiedID= 0b_00000000_00000001_00000000_00000000, //0x00010000
FW_InheritsModifiedID /**/= 0b_00000000_00010000_00000000_00000000, //0x00100000
FW_OverridesInheritanceBehaviorModifiedID = 0b_00000000_00100000_00000000_00000000, //0x00200000
FW_ShouldBeJournaledModifiedID /**/= 0b_00000001_00000000_00000000_00000000, //0x01000000
FW_UpdatesSourceOnLostFocusByDefaultID /**/= 0b_00000010_00000000_00000000_00000000, //0x02000000
FW_DefaultUpdateSourceTriggerModifiedID/**/= 0b_00000100_00000000_00000000_00000000, //0x04000000
FW_ReadOnlyID /**/= 0b_00001000_00000000_00000000_00000000, //0x08000000
FW_DefaultUpdateSourceTriggerEnumBit1 /**/= 0b_01000000_00000000_00000000_00000000, //0x40000000
FW_DefaultUpdateSourceTriggerEnumBit2 /**/= 0b_10000000_00000000_00000000_00000000, //0x80000000
;
Note also how the following three properties, all declared by FrameworkPropertyMetadata
, interact. To wit, IsDataBindingAllowed
is not the same as !IsNotDataBindable
; the former adds the additional restriction of ruling out the use of the incorrect binding direction for 'read-only' properties.
private bool ReadOnly => (_flags & FW_ReadOnlyID) != 0;
public bool IsDataBindingAllowed =>
(_flags & FW_IsNotDataBindableID) == 0 && !this.ReadOnly;
public bool IsNotDataBindable => (_flags & FW_IsNotDataBindableID) != 0;
[edit:] ALERT/WARNING: For some unknown reason, the flags shown above do not share the same values as those specified by the corresponding
FrameworkPropertyMetadataOptions
flag![Flags]
public enum FrameworkPropertyMetadataOptions
// FPMO MetadataFlags
// ---------- ----------
// 0x00000010 ←┐
None /**/ = 0x00000000, // │
AffectsMeasure /**/ = 0x00000001, // << 6 0x00000040 │
AffectsArrange /**/ = 0x00000002, // << 6 0x00000080 │
AffectsParentMeasure /**/ = 0x00000004, // << 6 0x00000100 │
AffectsParentArrange /**/ = 0x00000008, // << 6 0x00000200 │
AffectsRender /**/ = 0x00000010, // << 6 0x00000400 │
Inherits /**/ = 0x00000020, // >> 1 → → ────┘
OverridesInheritanceBehavior /**/ = 0x00000040, // << 5 0x00000800
NotDataBindable /**/ = 0x00000080, // << 5 0x00001000
BindsTwoWayByDefault /**/ = 0x00000100, // << 5 0x00002000
Journal /**/ = 0x00000400, // << 4 0x00004000
SubPropertiesDoNotAffectRender /**/ = 0x00000800, // << 4 0x00008000
;
All of the behaviors exposed by FrameworkPropertyMetadata
and UIPropertyMetadata
are controlled by flag bits that are recorded in a single enum
(32-bit uint
) field called _flags
which is declared in the PropertyMetadata
base class, even though none of the flags are actually publicly exposed from there. Here is the declaration of that enum
:
internal enum MetadataFlags : uint
DefaultValueModifiedID /**/= 0b_00000000_00000000_00000000_00000001, //0x00000001
SealedID /**/= 0b_00000000_00000000_00000000_00000010, //0x00000002
Inherited /**/= 0b_00000000_00000000_00000000_00010000, //0x00000010
UI_IsAnimationProhibitedID /**/= 0b_00000000_00000000_00000000_00100000, //0x00000020
FW_AffectsMeasureID /**/= 0b_00000000_00000000_00000000_01000000, //0x00000040
FW_AffectsArrangeID /**/= 0b_00000000_00000000_00000000_10000000, //0x00000080
FW_AffectsParentMeasureID /**/= 0b_00000000_00000000_00000001_00000000, //0x00000100
FW_AffectsParentArrangeID /**/= 0b_00000000_00000000_00000010_00000000, //0x00000200
FW_AffectsRenderID /**/= 0b_00000000_00000000_00000100_00000000, //0x00000400
FW_OverridesInheritanceBehaviorID /**/= 0b_00000000_00000000_00001000_00000000, //0x00000800
FW_IsNotDataBindableID /**/= 0b_00000000_00000000_00010000_00000000, //0x00001000
FW_BindsTwoWayByDefaultID /**/= 0b_00000000_00000000_00100000_00000000, //0x00002000
FW_ShouldBeJournaledID /**/= 0b_00000000_00000000_01000000_00000000, //0x00004000
FW_SubPropertiesDoNotAffectRenderID /**/= 0b_00000000_00000000_10000000_00000000, //0x00008000
FW_SubPropertiesDoNotAffectRenderModifiedID= 0b_00000000_00000001_00000000_00000000, //0x00010000
FW_InheritsModifiedID /**/= 0b_00000000_00010000_00000000_00000000, //0x00100000
FW_OverridesInheritanceBehaviorModifiedID = 0b_00000000_00100000_00000000_00000000, //0x00200000
FW_ShouldBeJournaledModifiedID /**/= 0b_00000001_00000000_00000000_00000000, //0x01000000
FW_UpdatesSourceOnLostFocusByDefaultID /**/= 0b_00000010_00000000_00000000_00000000, //0x02000000
FW_DefaultUpdateSourceTriggerModifiedID/**/= 0b_00000100_00000000_00000000_00000000, //0x04000000
FW_ReadOnlyID /**/= 0b_00001000_00000000_00000000_00000000, //0x08000000
FW_DefaultUpdateSourceTriggerEnumBit1 /**/= 0b_01000000_00000000_00000000_00000000, //0x40000000
FW_DefaultUpdateSourceTriggerEnumBit2 /**/= 0b_10000000_00000000_00000000_00000000, //0x80000000
;
Note also how the following three properties, all declared by FrameworkPropertyMetadata
, interact. To wit, IsDataBindingAllowed
is not the same as !IsNotDataBindable
; the former adds the additional restriction of ruling out the use of the incorrect binding direction for 'read-only' properties.
private bool ReadOnly => (_flags & FW_ReadOnlyID) != 0;
public bool IsDataBindingAllowed =>
(_flags & FW_IsNotDataBindableID) == 0 && !this.ReadOnly;
public bool IsNotDataBindable => (_flags & FW_IsNotDataBindableID) != 0;
[edit:] ALERT/WARNING: For some unknown reason, the flags shown above do not share the same values as those specified by the corresponding
FrameworkPropertyMetadataOptions
flag![Flags]
public enum FrameworkPropertyMetadataOptions
// FPMO MetadataFlags
// ---------- ----------
// 0x00000010 ←┐
None /**/ = 0x00000000, // │
AffectsMeasure /**/ = 0x00000001, // << 6 0x00000040 │
AffectsArrange /**/ = 0x00000002, // << 6 0x00000080 │
AffectsParentMeasure /**/ = 0x00000004, // << 6 0x00000100 │
AffectsParentArrange /**/ = 0x00000008, // << 6 0x00000200 │
AffectsRender /**/ = 0x00000010, // << 6 0x00000400 │
Inherits /**/ = 0x00000020, // >> 1 → → ────┘
OverridesInheritanceBehavior /**/ = 0x00000040, // << 5 0x00000800
NotDataBindable /**/ = 0x00000080, // << 5 0x00001000
BindsTwoWayByDefault /**/ = 0x00000100, // << 5 0x00002000
Journal /**/ = 0x00000400, // << 4 0x00004000
SubPropertiesDoNotAffectRender /**/ = 0x00000800, // << 4 0x00008000
;
edited Mar 28 at 4:26
answered Mar 28 at 3:44


Glenn SlaydenGlenn Slayden
10.2k2 gold badges70 silver badges80 bronze badges
10.2k2 gold badges70 silver badges80 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14221636%2fwhat-are-the-differences-among-propertymetadata-uipropertymetadata-and-framewo%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You could easily create 3 dependency properties yourself and observe the results. Then if you still have a specific problem, come and ask a question.
– Benjamin Gale
Jan 8 '13 at 18:29
I have just started playing with Dependency properties. But to get acquainted with all these 3 classes I am seeking a simple example, if you write and explain, it will very helpful for me. Thanks.
– WpfBee
Jan 8 '13 at 18:35
1
wpf.2000things.com/2012/06/07/…
– eran otzap
Feb 10 '15 at 7:34