static CustomDrawnElement() { FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata(Colors.Yellow); metadata.AffectsRender = true; BackgroundColorProperty = DependencyProperty.Register("BackgroundColor", typeof(Color), typeof(CustomDrawnElement), metadata); }
static VerticalPanel() { //tell DP sub system, this DP, will affect //Arrange and Measure phases var metadata = new FrameworkPropertyMetadata {AffectsArrange = true, AffectsMeasure = true}; ColumnBreakBeforeProperty = DependencyProperty.RegisterAttached("ColumnBreakBefore",typeof(bool), typeof(VerticalPanel),metadata); }
/// <summary> /// Static Constructor /// </summary> static MaskedTextBox() { //override the meta data for the Text Proeprty of the textbox FrameworkPropertyMetadata metaData = new FrameworkPropertyMetadata(); metaData.CoerceValueCallback = ForceText; TextProperty.OverrideMetadata(typeof(MaskedTextBox), metaData); }
static LixeiraProperty() { var metadata = new FrameworkPropertyMetadata((ImageSource)null); ImageProperty = DependencyProperty.RegisterAttached("Image", typeof(ImageSource), typeof(LixeiraProperty), metadata); }
public OriginElement() { FrameworkPropertyMetadata meta = new FrameworkPropertyMetadata(); meta.AffectsRender = true; OriginProperty = DependencyProperty.Register("Origin", typeof(Point), typeof(OriginElement), meta); }
static ControlBehaviors() { //register dependency property FrameworkPropertyMetadata md = new FrameworkPropertyMetadata(null, DragsWindowPropertyChanged); DragsWindowProperty = DependencyProperty.RegisterAttached("DragsWindow", typeof(Window), typeof(ControlBehaviors), md); }
public void Should_Merge_Metadata_If_Supplied() { FrameworkPropertyMetadata metadata1 = new FrameworkPropertyMetadata( "foo", FrameworkPropertyMetadataOptions.Inherits, this.PropertyChangedCallback1, this.CoerceCallback1); DependencyProperty dp = DependencyProperty.Register( "Should_Merge_Metadata_If_Supplied", typeof(string), typeof(TestClass1), metadata1); FrameworkPropertyMetadata metadata2 = new FrameworkPropertyMetadata( "bar", FrameworkPropertyMetadataOptions.Inherits | FrameworkPropertyMetadataOptions.AffectsRender, this.PropertyChangedCallback2, this.CoerceCallback2); dp.AddOwner(typeof(TestClass2), metadata2); FrameworkPropertyMetadata result = dp.GetMetadata(typeof(TestClass2)) as FrameworkPropertyMetadata; Assert.IsNotNull(result); Assert.AreNotSame(metadata1, result); Assert.AreSame(metadata2, result); Assert.AreEqual("bar", result.DefaultValue); Assert.IsTrue(result.Inherits); Assert.IsTrue(result.AffectsRender); Assert.AreEqual(2, result.PropertyChangedCallback.GetInvocationList().Length); Assert.AreEqual(1, result.CoerceValueCallback.GetInvocationList().Length); }
static MainWindow() { FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata(); metadata.Inherits = true; SpaceProperty = SpaceButton.SpaceProperty.AddOwner(typeof(MainWindow)); SpaceProperty.OverrideMetadata(typeof(Window), metadata); }
//-------------------------------------------------------------------- // // Constructors // //--------------------------------------------------------------------- #region Constructors static FixedPage() { FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata(FlowDirection.LeftToRight, FrameworkPropertyMetadataOptions.AffectsParentArrange); metadata.CoerceValueCallback = new CoerceValueCallback(CoerceFlowDirection); FlowDirectionProperty.OverrideMetadata(typeof(FixedPage), metadata); // This puts the origin always at the top left of the page and prevents mirroring unless this is overridden. }
static SpaceButton() { FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata(); metadata.DefaultValue = 0; metadata.PropertyChangedCallback += OnSpacePropertyChanged; metadata.Inherits = true; SpaceProperty = DependencyProperty.Register("Space", typeof(int), typeof(SpaceButton), metadata, ValidateSpaceValue); }
static TabControlExtension() { //register attached dependency property var metadata = new FrameworkPropertyMetadata(new SolidColorBrush(Colors.Red)); HeaderBackgroundProperty = DependencyProperty.RegisterAttached("HeaderBackground", typeof (Brush), typeof (TabControlExtension), metadata); }
static TitleMenu() { //register attached dependency property var metadata = new FrameworkPropertyMetadata((object)null); ContentProperty = DependencyProperty.RegisterAttached("Content", typeof(object), typeof(TitleMenu), metadata); }
static ImageSourceDep() { //register attached dependency property var metadata = new FrameworkPropertyMetadata((ImageSource) null); ImageProperty = DependencyProperty.RegisterAttached("Image", typeof (ImageSource), typeof(ImageSourceDep), metadata); }
static WrapBreakPanel() { FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata(); metadata.AffectsArrange = true; metadata.AffectsMeasure = true; LineBreakBeforeProperty = DependencyProperty.RegisterAttached("LineBreakBefore", typeof(bool), typeof(WrapBreakPanel), metadata); }
static ObtieneImagen() { var metadata = new FrameworkPropertyMetadata((ImageSource) null); ImageProperty = DependencyProperty.RegisterAttached("Image", typeof(ImageSource), typeof(ObtieneImagen), metadata); }
static ColorComboBox() { ms_IsSortedByBrightnessProperty = DependencyProperty.Register("IsSortedByBrightness", typeof(bool), typeof(ColorComboBox)); FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata(); metadata.BindsTwoWayByDefault = true; metadata.PropertyChangedCallback = new PropertyChangedCallback(OnBrushChanged); metadata.DefaultUpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; SelectedBrushProperty = DependencyProperty.Register("SelectedBrush", typeof(Brush), typeof(ColorComboBox), metadata); }
/// <summary> /// Initializes the <see cref="SessionView" /> class. /// </summary> static SessionView() { var propertyMetadata = new FrameworkPropertyMetadata(RESX.EmptySession) { CoerceValueCallback = OnCoerceTitleCallBack }; TitleProperty.OverrideMetadata(typeof (SessionView), propertyMetadata); }
static PageWithPersistentData() { FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata(); metadata.Journal = true; MyPageDataProperty = DependencyProperty.Register( "MyPageDataProperty", typeof(string), typeof(PageWithPersistentData), metadata, null); }
public static DependencyProperty Register(string name, Type propertyType, Type ownerType, FrameworkPropertyMetadata typeMetadata) { DependencyProperty dp = DependencyProperty.Register(name, propertyType, ownerType, typeMetadata); #if SILVERLIGHT if (typeMetadata != null && typeMetadata.CoerceValueCallback != null) FrameworkPropertyMetadata.AssociatePropertyWithCoercionMethod(dp, typeMetadata.CoerceValueCallback); #endif return dp; }
static KNActionCellDependencyProperty() { //register attached dependency property var nullMetadata = new FrameworkPropertyMetadata(null); DelegateProperty = DependencyProperty.RegisterAttached("Delegate", typeof(KNActionCellDelegate), typeof(KNActionCellDependencyProperty), nullMetadata); }
public DocumentContainer() { InitializeComponent(); //register dockstate dependency property var metadata = new FrameworkPropertyMetadata(DockStates.Floating); DockState = DependencyProperty.RegisterAttached("DockState", typeof(DockStates), typeof(DocumentContainer), metadata); }
static ExampleCtrl() { FrameworkPropertyMetadata textMetadata = new FrameworkPropertyMetadata(String.Empty, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsParentMeasure | FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(OnTextChanged), new CoerceValueCallback(OnCoerceText), true); ExampleCtrl.TextProperty = DependencyProperty.Register("Text", typeof(String), typeof(ExampleCtrl), textMetadata); }
static ShelfRowUnit() { BookItemClickEvent = EventManager.RegisterRoutedEvent("BookItemClicked", RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler<BookItemView>), typeof(ShelfRowUnit)); BookItemRemovedEvent = EventManager.RegisterRoutedEvent("BookItemRemoved", RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler<BookItemView>), typeof(ShelfRowUnit)); FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsMeasure, new PropertyChangedCallback(OnBooksRowChanged)); BooksRowProperty = DependencyProperty.Register("BooksRow", typeof(ShelfRowBooks), typeof(ShelfRowUnit), metadata, null); }
static DataGridProperties() { var metadata = new FrameworkPropertyMetadata((Brush)null); HeaderBrushProperty = DependencyProperty.RegisterAttached("HeaderBrush", typeof(Brush), typeof(DataGridProperties), metadata); DataGridRollbackOnUnfocusedProperty = DependencyProperty.RegisterAttached("DataGridRollbackOnUnfocused", typeof(bool), typeof(DataGridProperties), new UIPropertyMetadata(false, OnDataGridRollbackOnUnfocusedChanged)); DataGridMiddleButtonScrollProperty = DependencyProperty.RegisterAttached("DataGridMiddleButtonScroll", typeof(bool), typeof(DataGridProperties), new UIPropertyMetadata(false, OnDataGridMiddleButtonScrollChanged)); }
static TabbedExpanderPanel() { //tell DP sub system, this DP, will affect //Arrange and Measure phases FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata(); metadata.AffectsArrange = true; metadata.AffectsMeasure = true; ElemHeightProperty = DependencyProperty.RegisterAttached("ElemHeight", typeof(int), typeof(TabbedExpanderPanel), metadata); }
//#region Image dependency property ///// <summary> ///// An attached dependency property which provides an ///// <see cref="ImageSource" /> for arbitrary WPF elements. ///// </summary> //public static readonly DependencyProperty ImageSizeProperty; ///// <summary> ///// Gets the <see cref="ImageProperty"/> for a given ///// <see cref="DependencyObject"/>, which provides an ///// <see cref="ImageSource" /> for arbitrary WPF elements. ///// </summary> //public static int GetImageSize(DependencyObject obj) //{ // return (int)obj.GetValue(ImageProperty); //} ///// <summary> ///// Sets the attached <see cref="ImageProperty"/> for a given ///// <see cref="DependencyObject"/>, which provides an ///// <see cref="ImageSource" /> for arbitrary WPF elements. ///// </summary> //public static void SetImageSize(DependencyObject obj, int value) //{ // obj.SetValue(ImageSizeProperty, value); //} //#endregion static AttachedProperties() { //register attached dependency property var metadata = new FrameworkPropertyMetadata((ImageSource) null); ImageProperty = DependencyProperty.RegisterAttached("Image", typeof (ImageSource), typeof (AttachedProperties), metadata); //ImageSizeProperty = DependencyProperty.RegisterAttached("ImageSize", // typeof(int), // typeof(AttachedProperties), metadata); }
public static void SetXmlLanguage(CultureInfo culture) { var lang = XmlLanguage.GetLanguage(culture.Name); SetCulture(lang, culture); var meteadata = new FrameworkPropertyMetadata(lang); if (!isInit) { FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), meteadata); isInit = true; } }
static MaskedTextBox() { MaskProperty = DependencyProperty.Register("Mask", typeof(string), typeof(MaskedTextBox), new FrameworkPropertyMetadata(MaskChanged)); FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata(); metadata.CoerceValueCallback = CoerceText; TextProperty.OverrideMetadata(typeof(MaskedTextBox), metadata); CommandManager.RegisterClassCommandBinding(typeof(MaskedTextBox), new CommandBinding(ApplicationCommands.Paste, null)); }
public void Registered_Class_Should_Return_Metadata() { FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata("foo"); DependencyProperty dp = DependencyProperty.Register( "Registered_Class_Should_Return_Metadata", typeof(string), typeof(TestClass1), metadata); PropertyMetadata result = dp.GetMetadata(typeof(TestClass1)); Assert.AreSame(metadata, result); }
public static readonly DependencyProperty SidesProperty; // By convention, add the suffix Property to your dependency properties #endregion Fields #region Constructors static MainWindow() { // Create a FrameworkPropertyMetadata object that will contain information // regarding how the WPF property system should handle SidesProperty dependency property FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata(); metadata.PropertyChangedCallback = OnSidesChange; // Register SidesProperty in the WPF property system // When a dependency property is registered in WPF property system via Register, it returns a property identifier SidesProperty = DependencyProperty.Register("Sides", // Dependency property typeof (int), // Type of the Property typeof (MainWindow), // Owner of the Property metadata); // Reference to metadata }
public static void CoerceValue(DependencyObject d, DependencyProperty dp) { FrameworkPropertyMetadata.DoExplicitCoercion(d, dp); }
// Token: 0x06000C59 RID: 3161 RVA: 0x0002DFDC File Offset: 0x0002C1DC internal FrugalObjectList <DependencyProperty> CreateParentInheritableProperties(DependencyObject d, DependencyObject parent, bool isAddOperation) { if (parent == null) { return(new FrugalObjectList <DependencyProperty>(0)); } DependencyObjectType dependencyObjectType = d.DependencyObjectType; EffectiveValueEntry[] array = null; uint num = 0U; uint num2 = 0U; if (!parent.IsSelfInheritanceParent) { DependencyObject inheritanceParent = parent.InheritanceParent; if (inheritanceParent != null) { array = inheritanceParent.EffectiveValues; num = inheritanceParent.EffectiveValuesCount; num2 = inheritanceParent.InheritableEffectiveValuesCount; } } else { array = parent.EffectiveValues; num = parent.EffectiveValuesCount; num2 = parent.InheritableEffectiveValuesCount; } FrugalObjectList <DependencyProperty> frugalObjectList = new FrugalObjectList <DependencyProperty>((int)num2); if (num2 == 0U) { return(frugalObjectList); } this._rootInheritableValues = new InheritablePropertyChangeInfo[num2]; int num3 = 0; FrameworkObject frameworkObject = new FrameworkObject(parent); for (uint num4 = 0U; num4 < num; num4 += 1U) { EffectiveValueEntry effectiveValueEntry = array[(int)num4]; DependencyProperty dependencyProperty = DependencyProperty.RegisteredPropertyList.List[effectiveValueEntry.PropertyIndex]; if (dependencyProperty != null && dependencyProperty.IsPotentiallyInherited) { PropertyMetadata metadata = dependencyProperty.GetMetadata(parent.DependencyObjectType); if (metadata != null && metadata.IsInherited) { FrameworkPropertyMetadata frameworkPropertyMetadata = (FrameworkPropertyMetadata)metadata; if (!TreeWalkHelper.SkipNow(frameworkObject.InheritanceBehavior) || frameworkPropertyMetadata.OverridesInheritanceBehavior) { frugalObjectList.Add(dependencyProperty); EffectiveValueEntry valueEntry = d.GetValueEntry(d.LookupEntry(dependencyProperty.GlobalIndex), dependencyProperty, dependencyProperty.GetMetadata(dependencyObjectType), RequestFlags.DeferredReferences); EffectiveValueEntry newEntry; if (isAddOperation) { newEntry = effectiveValueEntry; if (newEntry.BaseValueSourceInternal != BaseValueSourceInternal.Default || newEntry.HasModifiers) { newEntry = newEntry.GetFlattenedEntry(RequestFlags.FullyResolved); newEntry.BaseValueSourceInternal = BaseValueSourceInternal.Inherited; } } else { newEntry = default(EffectiveValueEntry); } this._rootInheritableValues[num3++] = new InheritablePropertyChangeInfo(d, dependencyProperty, valueEntry, newEntry); if ((ulong)num2 == (ulong)((long)num3)) { break; } } } } } return(frugalObjectList); }
// // This method // 1. Is called from AncestorChange InvalidateTree. // 2. It is used to create the InheritableProperties on the given node. // 3. It also accumulates oldValues for the inheritable properties that are about to be invalidated // internal FrugalObjectList <DependencyProperty> CreateParentInheritableProperties( DependencyObject d, DependencyObject parent, bool isAddOperation) { Debug.Assert(d != null, "Must have non-null current node"); if (parent == null) { return(new FrugalObjectList <DependencyProperty>(0)); } DependencyObjectType treeObjDOT = d.DependencyObjectType; // See if we have a cached value. EffectiveValueEntry[] parentEffectiveValues = null; uint parentEffectiveValuesCount = 0; uint inheritablePropertiesCount = 0; // If inheritable properties aren't cached on you then use the effective // values cache on the parent to discover those inherited properties that // may need to be invalidated on the children nodes. if (!parent.IsSelfInheritanceParent) { DependencyObject inheritanceParent = parent.InheritanceParent; if (inheritanceParent != null) { parentEffectiveValues = inheritanceParent.EffectiveValues; parentEffectiveValuesCount = inheritanceParent.EffectiveValuesCount; inheritablePropertiesCount = inheritanceParent.InheritableEffectiveValuesCount; } } else { parentEffectiveValues = parent.EffectiveValues; parentEffectiveValuesCount = parent.EffectiveValuesCount; inheritablePropertiesCount = parent.InheritableEffectiveValuesCount; } FrugalObjectList <DependencyProperty> inheritableProperties = new FrugalObjectList <DependencyProperty>((int)inheritablePropertiesCount); if (inheritablePropertiesCount == 0) { return(inheritableProperties); } _rootInheritableValues = new InheritablePropertyChangeInfo[(int)inheritablePropertiesCount]; int inheritableIndex = 0; FrameworkObject foParent = new FrameworkObject(parent); for (uint i = 0; i < parentEffectiveValuesCount; i++) { // Add all the inheritable properties from the effectiveValues // cache to the TreeStateCache on the parent EffectiveValueEntry entry = parentEffectiveValues[i]; DependencyProperty dp = DependencyProperty.RegisteredPropertyList.List[entry.PropertyIndex]; // There are UncommonFields also stored in the EffectiveValues cache. We need to exclude those. if ((dp != null) && dp.IsPotentiallyInherited) { PropertyMetadata metadata = dp.GetMetadata(parent.DependencyObjectType); if (metadata != null && metadata.IsInherited) { Debug.Assert(!inheritableProperties.Contains(dp), "EffectiveValues cache must not contains duplicate entries for the same DP"); FrameworkPropertyMetadata fMetadata = (FrameworkPropertyMetadata)metadata; // Children do not need to inherit properties across a tree boundary // unless the property is set to override this behavior. if (!TreeWalkHelper.SkipNow(foParent.InheritanceBehavior) || fMetadata.OverridesInheritanceBehavior) { inheritableProperties.Add(dp); EffectiveValueEntry oldEntry; EffectiveValueEntry newEntry; oldEntry = d.GetValueEntry( d.LookupEntry(dp.GlobalIndex), dp, dp.GetMetadata(treeObjDOT), RequestFlags.DeferredReferences); if (isAddOperation) { // set up the new value newEntry = entry; if ((newEntry.BaseValueSourceInternal != BaseValueSourceInternal.Default) || newEntry.HasModifiers) { newEntry = newEntry.GetFlattenedEntry(RequestFlags.FullyResolved); newEntry.BaseValueSourceInternal = BaseValueSourceInternal.Inherited; } } else { newEntry = new EffectiveValueEntry(); } _rootInheritableValues[inheritableIndex++] = new InheritablePropertyChangeInfo(d, dp, oldEntry, newEntry); if (inheritablePropertiesCount == inheritableIndex) { // no more inheritable properties, bail early break; } } } } } return(inheritableProperties); }
// Token: 0x06000C66 RID: 3174 RVA: 0x0002E490 File Offset: 0x0002C690 private static bool InvalidateTreeDependentProperty(TreeChangeInfo info, DependencyObject d, ref FrameworkObject fo, DependencyProperty dp, FrameworkPropertyMetadata fMetadata, Style selfStyle, Style selfThemeStyle, ref ChildRecord childRecord, bool isChildRecordValid, bool hasStyleChanged, bool isSelfInheritanceParent, bool wasSelfInheritanceParent) { if (!TreeWalkHelper.SkipNext(fo.InheritanceBehavior) || fMetadata.OverridesInheritanceBehavior) { InheritablePropertyChangeInfo rootInheritableValue = info.GetRootInheritableValue(dp); EffectiveValueEntry oldEntry = rootInheritableValue.OldEntry; EffectiveValueEntry effectiveValueEntry = info.IsAddOperation ? rootInheritableValue.NewEntry : new EffectiveValueEntry(dp, BaseValueSourceInternal.Inherited); bool flag = TreeWalkHelper.IsForceInheritedProperty(dp); if (d != info.Root) { if (wasSelfInheritanceParent) { oldEntry = d.GetValueEntry(d.LookupEntry(dp.GlobalIndex), dp, fMetadata, RequestFlags.DeferredReferences); } else if (isSelfInheritanceParent) { EffectiveValueEntry valueEntry = d.GetValueEntry(d.LookupEntry(dp.GlobalIndex), dp, fMetadata, RequestFlags.DeferredReferences); if (valueEntry.BaseValueSourceInternal <= BaseValueSourceInternal.Inherited) { oldEntry = oldEntry.GetFlattenedEntry(RequestFlags.FullyResolved); oldEntry.BaseValueSourceInternal = BaseValueSourceInternal.Inherited; } else { oldEntry = valueEntry; } } else { oldEntry = oldEntry.GetFlattenedEntry(RequestFlags.FullyResolved); oldEntry.BaseValueSourceInternal = BaseValueSourceInternal.Inherited; } } else if (info.IsAddOperation && (flag || oldEntry.BaseValueSourceInternal <= BaseValueSourceInternal.Inherited)) { EffectiveValueEntry valueEntry2 = d.GetValueEntry(d.LookupEntry(dp.GlobalIndex), dp, fMetadata, RequestFlags.DeferredReferences); if (valueEntry2.BaseValueSourceInternal > BaseValueSourceInternal.Inherited) { oldEntry = valueEntry2; } } OperationType operationType = info.IsAddOperation ? OperationType.AddChild : OperationType.RemoveChild; if (BaseValueSourceInternal.Inherited >= oldEntry.BaseValueSourceInternal) { return((d.UpdateEffectiveValue(d.LookupEntry(dp.GlobalIndex), dp, fMetadata, oldEntry, ref effectiveValueEntry, false, false, operationType) & (UpdateResult)5) == UpdateResult.ValueChanged); } if (flag) { effectiveValueEntry = new EffectiveValueEntry(dp, FullValueSource.IsCoerced); return((d.UpdateEffectiveValue(d.LookupEntry(dp.GlobalIndex), dp, fMetadata, oldEntry, ref effectiveValueEntry, false, false, operationType) & (UpdateResult)5) == UpdateResult.ValueChanged); } } return(false); }