本文整理汇总了C#中System.Windows.Controls.TextBlock.ReadLocalValue方法的典型用法代码示例。如果您正苦于以下问题:C# TextBlock.ReadLocalValue方法的具体用法?C# TextBlock.ReadLocalValue怎么用?C# TextBlock.ReadLocalValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.TextBlock
的用法示例。
在下文中一共展示了TextBlock.ReadLocalValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindDataContext
public void BindDataContext ()
{
// Bind the DataContext of the FE to its DataContext
TextBlock block = new TextBlock ();
block.SetBinding (TextBlock.DataContextProperty, new Binding ());
CreateAsyncTest (block,
() => Assert.IsNull (block.DataContext, "#1"),
() => TestPanel.DataContext = "Hello",
() => {
Assert.AreEqual ("Hello", block.DataContext, "#2");
Assert.IsInstanceOfType<BindingExpressionBase> (block.ReadLocalValue (TextBlock.DataContextProperty), "#3");
}
);
}
示例2: PromotingDefaultValue
public void PromotingDefaultValue ()
{
TextBlock tb = new TextBlock ();
tb.Text = "Hi there";
Storyboard sb = new Storyboard { Duration = new Duration (TimeSpan.FromMilliseconds(500)) };
ColorAnimation anim = new ColorAnimation { To = Colors.Blue, Duration = new Duration (TimeSpan.FromSeconds(0)) };
Storyboard.SetTarget (anim, tb);
Storyboard.SetTargetProperty (anim, new PropertyPath ("(TextBlock.Foreground).(SolidColorBrush.Color)"));
sb.Children.Add (anim);
Assert.AreEqual (DependencyProperty.UnsetValue, tb.ReadLocalValue (TextBlock.ForegroundProperty), "#0");
bool completed = false;
sb.Completed += (o,e) => completed = true;
sb.Begin ();
// beginning the storyboard promotes default values to local values.
Assert.AreNotEqual (DependencyProperty.UnsetValue, tb.ReadLocalValue (TextBlock.ForegroundProperty), "#1");
// but the value is identical to the default value (i.e. SolidColorBrush ("Black"))
Assert.AreEqual (Colors.Black, ((SolidColorBrush)tb.ReadLocalValue (TextBlock.ForegroundProperty)).Color, "#2");
EnqueueConditional (() => completed);
Enqueue (() => { Console.WriteLine ("testing animated value"); Assert.AreEqual (Colors.Blue, ((SolidColorBrush)tb.ReadLocalValue (TextBlock.ForegroundProperty)).Color, "#3"); });
EnqueueTestComplete ();
}