当前位置: 首页>>代码示例>>C#>>正文


C# TextBlock.ReadLocalValue方法代码示例

本文整理汇总了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");
				}
			);
		}
开发者ID:shana,项目名称:moon,代码行数:14,代码来源:BindingTest.cs

示例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 ();
		}
开发者ID:snorp,项目名称:moon,代码行数:32,代码来源:StoryboardTest.cs


注:本文中的System.Windows.Controls.TextBlock.ReadLocalValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。