本文整理汇总了C#中System.Windows.DependencyObject类的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject类的具体用法?C# DependencyObject怎么用?C# DependencyObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DependencyObject类属于System.Windows命名空间,在下文中一共展示了DependencyObject类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetBouyancy
public abstract class AquariumObject3 : DependencyObject
{
public enum Bouyancy
{
Floats,
Sinks,
Drifts
}
public static readonly DependencyProperty BouyancyProperty = DependencyProperty.RegisterAttached(
"Bouyancy",
typeof(Bouyancy),
typeof(AquariumObject3),
new FrameworkPropertyMetadata(Bouyancy.Floats, FrameworkPropertyMetadataOptions.AffectsArrange),
new ValidateValueCallback(ValidateBouyancy)
);
public static void SetBouyancy(UIElement element, Bouyancy value)
{
element.SetValue(BouyancyProperty, value);
}
public static Bouyancy GetBouyancy(UIElement element)
{
return (Bouyancy)element.GetValue(BouyancyProperty);
}
private static bool ValidateBouyancy(object value)
{
Bouyancy bTest = (Bouyancy) value;
return (bTest == Bouyancy.Floats || bTest == Bouyancy.Drifts || bTest==Bouyancy.Sinks);
}
public static readonly DependencyProperty IsDirtyProperty = DependencyProperty.Register(
"IsDirty",
typeof(Boolean),
typeof(AquariumObject3)
);
}