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


C# Canvas.GetValue方法代码示例

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


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

示例1: Register_HuhTest1

		public void Register_HuhTest1 ()
		{
			DependencyPropertyInfo info = new DependencyPropertyInfo ("Custom", typeof (InkPresenter), typeof (int), true);
			DependencyProperty property = info.Property;
			Canvas canvas = new Canvas ();

			canvas.GetValue (property); // This should throw, the property doesn't exist on the canvas.

			Assert.Throws (delegate { canvas.GetValue (InkPresenter.StrokesProperty); }, typeof (Exception)); // And this throws a catastrophic error.
		}
开发者ID:dfr0,项目名称:moon,代码行数:10,代码来源:DependencyPropertyAttachedTest.cs

示例2: Register_Canvas_Custom_Canvas

		public void Register_Canvas_Custom_Canvas ()
		{
			Canvas canvas = new Canvas ();
			CustomCanvasType custom_canvas = new CustomCanvasType ();
			DependencyProperty property;
			DependencyPropertyInfo info;
			DependencyPropertyInfo.ChangedInfo changed_info;
			InkPresenter ink = new InkPresenter (); // The only builtin type derived from Canvas
			object actual_value;
			object previous_expected_value = null;
			int iterations = 0;
			int changes = 0;

			Canvas_Custom_Canvas = new DependencyPropertyInfo ("Custom", typeof (Canvas), typeof (Canvas), true);
			info = Canvas_Custom_Canvas;

			property = info.Property;

			Assert.IsNull (canvas.GetValue (property));
			Assert.IsNull (ink.GetValue (property));

			Assert.Throws (delegate { canvas.SetValue (property, 1); }, typeof (ArgumentException));
			Assert.Throws (delegate { canvas.SetValue (property, ""); }, typeof (ArgumentException));
			Assert.Throws (delegate { canvas.SetValue (property, new CustomClass ()); }, typeof (ArgumentException));

			foreach (object expected_value in new object [] { null, new Canvas (), null, canvas, canvas, null, new CustomCanvasType (), custom_canvas, custom_canvas, ink }) {
				iterations++;

				canvas.SetValue (property, expected_value);
				actual_value = canvas.GetValue (property);

				if (expected_value != previous_expected_value) {
					changes++;
					changed_info = info.Changes [info.Changes.Count - 1];
					DependencyPropertyChangedEventArgs args = changed_info.args;
					Assert.AreSame (args.OldValue, previous_expected_value);
					Assert.AreSame (args.NewValue, expected_value);
					Assert.AreSame (changed_info.obj, canvas);
				}

				previous_expected_value = expected_value;

				Assert.AreSame (expected_value, actual_value, "Iteration #{0}", iterations);
				Assert.AreEqual (changes, info.Changes.Count, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations, changes, info.Changes.Count);
			}
		}
开发者ID:dfr0,项目名称:moon,代码行数:46,代码来源:DependencyPropertyAttachedTest.cs

示例3: ComplexTarget12

		public void ComplexTarget12 ()
		{
			bool complete = false;
			Storyboard sb = (Storyboard) XamlReader.Load (
@"<Storyboard xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
              xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
	<DoubleAnimation Duration=""0:0:0.05"" Storyboard.TargetName=""target"" Storyboard.TargetProperty=""Top"" To=""50"" />
</Storyboard>");
			sb.Completed += delegate { complete = true; };
			Canvas c = new Canvas ();
			Storyboard.SetTarget (sb, c);
			Enqueue (() => { TestPanel.Children.Add (c); TestPanel.Resources.Add ("a", sb); });
			Enqueue (() => sb.Begin ());
			EnqueueConditional (() => complete);
			Enqueue (() => Assert.AreEqual (50.0, c.GetValue (Canvas.TopProperty)));
			Enqueue (() => { TestPanel.Children.Clear (); TestPanel.Resources.Clear (); });
			EnqueueTestComplete ();
		}
开发者ID:kangaroo,项目名称:moon,代码行数:18,代码来源:StoryboardTest.cs


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