本文整理汇总了C#中System.Windows.Shapes.Rectangle.ClearValue方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.ClearValue方法的具体用法?C# Rectangle.ClearValue怎么用?C# Rectangle.ClearValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Shapes.Rectangle
的用法示例。
在下文中一共展示了Rectangle.ClearValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Check_Default
public void Check_Default ()
{
DependencyProperty property = DependencyProperty.Register ("MyProp", typeof (int), typeof(Rectangle), new PropertyMetadata (100));
Rectangle r = new Rectangle ();
r.SetValue (property, 10);
Assert.AreEqual (10, r.GetValue (property), "#1");
r.ClearValue (property);
Assert.AreEqual (100, r.GetValue (property), "#2");
}
示例2: Check_Default_Nullable
public void Check_Default_Nullable ()
{
DependencyProperty property = DependencyProperty.Register ("MyPropNullable", typeof (int?), typeof(Rectangle), null);
Rectangle r = new Rectangle ();
r.SetValue (property, 10);
Assert.AreEqual (10, r.GetValue (property), "#1");
r.ClearValue (property);
Assert.AreEqual (null, r.GetValue (property), "#2");
}
示例3: BasicBind
public void BasicBind ()
{
Rectangle rectangle = new Rectangle ();
Binding binding = new Binding ("Opacity");
binding.Source = new Data { Opacity = 0.0 };
rectangle.SetBinding (Rectangle.OpacityProperty, binding);
Assert.AreEqual (0.0, rectangle.Opacity, "#1");
Assert.IsTrue (rectangle.ReadLocalValue (Rectangle.OpacityProperty) is BindingExpressionBase, "#2");
rectangle.Opacity = 1.0;
Assert.AreEqual(1.0, rectangle.Opacity, "#3");
Assert.AreEqual (1.0, rectangle.ReadLocalValue (Rectangle.OpacityProperty), "#4");
rectangle.SetBinding (Rectangle.OpacityProperty, binding);
Assert.IsTrue (rectangle.ReadLocalValue (Rectangle.OpacityProperty) is BindingExpressionBase, "#5");
Assert.AreEqual (0.0, rectangle.Opacity, "#6");
rectangle.ClearValue (Rectangle.OpacityProperty);
Assert.AreEqual (1.0, rectangle.Opacity, "#7");
Assert.AreEqual (DependencyProperty.UnsetValue, rectangle.ReadLocalValue (Rectangle.OpacityProperty), "#8");
}
示例4: DataContext_ClearLocal
public void DataContext_ClearLocal ()
{
Binding b = new Binding("");
Canvas c = new Canvas();
c.DataContext = new SolidColorBrush(Colors.Blue);
Rectangle r = new Rectangle();
r.DataContext = new SolidColorBrush(Colors.Green);
c.Children.Add(r);
r.SetBinding(Rectangle.FillProperty, b);
// clearing the value allows the inherited
// DataContext to be used again (and causes
// the bound property to be updated)
r.ClearValue (FrameworkElement.DataContextProperty);
Assert.AreEqual(c.DataContext, r.DataContext, "#1");
Assert.AreEqual(c.DataContext, r.Fill, "#2");
}
示例5: TestTwoWayBinding2
public void TestTwoWayBinding2()
{
PropertyUpdater data = new PropertyUpdater { Opacity = 0.5f };
Rectangle r = new Rectangle();
r.SetBinding(Rectangle.OpacityProperty, new Binding
{
Path = new PropertyPath("Opacity"),
Source = data,
Mode = BindingMode.TwoWay
});
Assert.AreEqual(0.5, r.Opacity, "#1");
Assert.AreEqual(0.5, data.Opacity, "#2");
data.Opacity = 0;
Assert.AreEqual(0.0, r.Opacity, "#3");
r.Opacity = 1;
Assert.IsTrue(r.ReadLocalValue(Rectangle.OpacityProperty) is BindingExpressionBase, "#4");
Assert.AreEqual(1, r.Opacity, "#5");
Assert.AreEqual(1, data.Opacity, "#6");
r.ClearValue(Rectangle.OpacityProperty);
r.Opacity = 0.5;
Assert.AreEqual(1, data.Opacity, "#7");
}
示例6: NullOldValue
public void NullOldValue ()
{
Rectangle r = new Rectangle ();
Style style = new Style (typeof (Rectangle));
style.Setters.Add (new Setter (FrameworkElement.WidthProperty, 100));
style.Setters.Add (new Setter (FrameworkElement.HeightProperty, "CRASH ME"));
r.Style = style;
r.Height = 2;
r.ClearValue (Rectangle.HeightProperty);
r.Height = 2;
r.ClearValue (Rectangle.HeightProperty);
}