本文整理汇总了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.
}
示例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);
}
}
示例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 ();
}