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


C# ContentPresenter.ReadLocalValue方法代码示例

本文整理汇总了C#中System.Windows.Controls.ContentPresenter.ReadLocalValue方法的典型用法代码示例。如果您正苦于以下问题:C# ContentPresenter.ReadLocalValue方法的具体用法?C# ContentPresenter.ReadLocalValue怎么用?C# ContentPresenter.ReadLocalValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.ContentPresenter的用法示例。


在下文中一共展示了ContentPresenter.ReadLocalValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BindContentPresenterContent

		public void BindContentPresenterContent ()
		{
			ContentPresenter presenter = new ContentPresenter ();
			presenter.SetBinding (ContentPresenter.ContentProperty, new Binding ("Opacity"));

			CustomControl c = new CustomControl { Content = presenter };
			CreateAsyncTest (c,
				() => {
					c.DataContext = new Data { Opacity = 1.0 };
				}, () => {
					Assert.AreEqual (1.0, presenter.ReadLocalValue (ContentPresenter.DataContextProperty), "#1");
					Assert.AreEqual (1.0, presenter.Content, "#2");

					c.DataContext = new Data { Opacity = 0.0 };
				}, () => {
					Assert.AreEqual (0.0, presenter.ReadLocalValue (ContentPresenter.DataContextProperty), "#3");
					Assert.AreEqual (0.0, presenter.Content, "#4");
				}
			);
		}
开发者ID:shana,项目名称:moon,代码行数:20,代码来源:BindingTest.cs

示例2: DataContextTest7

		public void DataContextTest7 ()
		{
			// A null content is copied to the datacontext too.
			ContentPresenter presenter = new ContentPresenter ();
			CreateAsyncTest (presenter,
				() => {
					presenter.Content = new object ();
				}, () => {
					Assert.AreEqual (presenter.Content, presenter.ReadLocalValue (ContentPresenter.DataContextProperty), "#1");
					presenter.Content = null;
				}, () => {
					Assert.AreEqual (null, presenter.ReadLocalValue (ContentPresenter.DataContextProperty), "#2");

				}
			);
		}
开发者ID:shana,项目名称:moon,代码行数:16,代码来源:ContentPresenterTest.cs

示例3: DataContextTest5b

		public void DataContextTest5b ()
		{
			// When the ContentPresenter is in the tree, its DataContext gets set to ContentPresenter.Content
			// when it is loaded
			object o = new object ();
			object content = new object ();
			ContentPresenter c = new ContentPresenter { Content = content };
			CreateAsyncTest (c,
				() => {
					Assert.AreEqual (content, c.DataContext, "#1");
					Assert.AreEqual (content, c.ReadLocalValue (FrameworkElement.DataContextProperty), "#2");
				}
			);
		}
开发者ID:shana,项目名称:moon,代码行数:14,代码来源:ContentPresenterTest.cs

示例4: DataContextTest5

		public void DataContextTest5 ()
		{
			// When the ContentPresenter is in the tree, its DataContext gets set to ContentPresenter.Content
			// when it is loaded
			object o = new object ();
			ContentPresenter c = new ContentPresenter { DataContext = o };
			Assert.AreEqual (o, c.DataContext, "#1");
			CreateAsyncTest (c,
				() => {
					Assert.IsNull (c.DataContext, "#2");
					Assert.IsNull (c.ReadLocalValue (ContentPresenter.DataContextProperty), "#2b");
				},
				() => {
					c.DataContext = o;
					Assert.AreEqual (o, c.DataContext, "#3");
					Assert.AreEqual (o, c.ReadLocalValue (ContentPresenter.DataContextProperty), "#3b");
				},
				() => Assert.AreEqual (o, c.DataContext, "#4")
			);
		}
开发者ID:shana,项目名称:moon,代码行数:20,代码来源:ContentPresenterTest.cs

示例5: DataContextTest2

		public void DataContextTest2 ()
		{
			// Changing the content updates the datacontext
			ContentPresenter c = new ContentPresenter ();
			c.Content = new object ();
			CreateAsyncTest (c,
				() => {
					Assert.AreEqual (c.Content, c.DataContext, "#1");
					Assert.AreEqual (c.Content, c.ReadLocalValue (ContentPresenter.DataContextProperty), "#1b");
					c.Content = new object ();
				},
				() => {
					Assert.AreEqual (c.Content, c.DataContext, "#2");
					Assert.AreEqual (c.Content, c.ReadLocalValue (ContentPresenter.DataContextProperty), "#2b");
				}
			);
		}
开发者ID:shana,项目名称:moon,代码行数:17,代码来源:ContentPresenterTest.cs

示例6: DataContextTest_DataContextUpdatesAsync

		public void DataContextTest_DataContextUpdatesAsync ()
		{
			var presenter = new ContentPresenter ();
			presenter.SetBinding (ContentPresenter.DataContextProperty, new Binding ());
			Assert.IsInstanceOfType<BindingExpression> (presenter.ReadLocalValue (ContentPresenter.DataContextProperty), "#1");

			presenter.Content = new object ();
			Assert.IsInstanceOfType<BindingExpression> (presenter.ReadLocalValue (ContentPresenter.DataContextProperty), "#2");

			TestPanel.Children.Add (presenter);
			Assert.IsInstanceOfType<BindingExpression> (presenter.ReadLocalValue (ContentPresenter.DataContextProperty), "#3");

			Enqueue (() => {
				Assert.AreSame (presenter.Content, presenter.ReadLocalValue (ContentPresenter.DataContextProperty), "#4");
			});
			EnqueueTestComplete ();
		}
开发者ID:dfr0,项目名称:moon,代码行数:17,代码来源:ContentPresenterTest.cs


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