本文整理汇总了C#中System.Windows.FrameworkElement.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElement.SetValue方法的具体用法?C# FrameworkElement.SetValue怎么用?C# FrameworkElement.SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.FrameworkElement
的用法示例。
在下文中一共展示了FrameworkElement.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetCommonBindings
protected override void SetCommonBindings(FrameworkElement marker)
{
base.SetCommonBindings(marker);
marker.SetValue(ViewportPanel.YProperty, 0.0);
marker.SetBinding(ViewportPanel.ViewportHeightProperty, DependentValueBinding);
marker.SetBinding(ViewportPanel.ViewportWidthProperty, ColumnWidthBinding);
marker.SetValue(ViewportPanel.ViewportVerticalAlignmentProperty, VerticalAlignment.Bottom);
marker.SetBinding(ViewportPanel.XProperty, IndexBinding);
}
示例2: Enemy
public Enemy(Field field, FrameworkElement ui)
: base(ui)
{
this.field = field;
this.right = -ui.ActualWidth;
this.bottom = (double)App.Random.Next(100);
ui.SetValue(Canvas.RightProperty, this.right);
ui.SetValue(Canvas.BottomProperty, this.bottom);
}
示例3: AddCommonBindings
protected override void AddCommonBindings(FrameworkElement marker)
{
base.AddCommonBindings(marker);
marker.SetValue(ViewportPanel.XProperty, 0.0);
marker.SetBinding(ViewportPanel.ViewportWidthProperty, viewportWidthBinding);
marker.SetValue(ViewportPanel.ViewportHeightProperty, 0.85);
marker.SetValue(ViewportPanel.ViewportHorizontalAlignmentProperty, HorizontalAlignment.Left);
marker.SetBinding(ViewportPanel.YProperty, viewportYBinding);
}
示例4: FreezableBasicTest
public void FreezableBasicTest()
{
int resourcesChangedCount = 0;
object resourceValue;
Freezable freezable = new Freezable();
freezable.ResourcesChanged += (sender, e) => resourcesChangedCount++;
FrameworkElement element = new FrameworkElement();
element.DataContext = "data-context";
element.Resources = new ResourceDictionary();
element.Resources.Add("key1", "value1");
Assert.AreNotEqual("data-context", freezable.GetValue(FrameworkElement.DataContextProperty));
Assert.IsFalse(freezable.TryGetResource("key1", out resourceValue));
element.SetValue(ValueProperty, freezable);
Assert.AreEqual("data-context", freezable.GetValue(FrameworkElement.DataContextProperty));
Assert.AreEqual(1, resourcesChangedCount);
Assert.IsTrue(freezable.TryGetResource("key1", out resourceValue));
Assert.AreEqual("value1", resourceValue);
element.Resources.Add("key2", "value2");
Assert.AreEqual(2, resourcesChangedCount);
Assert.IsTrue(freezable.TryGetResource("key2", out resourceValue));
Assert.AreEqual("value2", resourceValue);
}
示例5: SetupNextToolTip
public static void SetupNextToolTip(FrameworkElement element, Window window) {
element.ToolTip = GetNextToolTip(window);
if (element.ToolTip != null) {
element.SetValue(ToolTipService.ShowDurationProperty, 30000);
}
}
示例6: UpdateProperty
internal void UpdateProperty( FrameworkElement element, DependencyProperty elementProp, DependencyProperty definitionProperty )
{
object currentValue = this.GetValue( definitionProperty );
object localValue = this.ReadLocalValue( definitionProperty );
object elementValue = element.GetValue( elementProp );
bool areEquals = false;
// Avoid setting values if it does not affect anything
// because setting a local value may prevent a style setter from being active.
if( localValue != DependencyProperty.UnsetValue )
{
if( ( elementValue != null ) && ( currentValue != null ) )
{
areEquals = ( elementValue.GetType().IsValueType && currentValue.GetType().IsValueType )
? elementValue.Equals( currentValue ) // Value Types
: currentValue == element.GetValue( elementProp ); // Reference Types
}
if( !areEquals )
{
element.SetValue( elementProp, currentValue );
}
else
{
element.ClearValue( elementProp );
}
}
}
示例7: SetPosition
private static void SetPosition(FrameworkElement ellipse, double offset,
double posOffSet, double step, double ew, double eh, double w, double h,
double r)
{
double t = 2*Math.PI*posOffSet/10;
ellipse.Width = ew;
ellipse.Height = eh;
ellipse.SetValue(Canvas.LeftProperty, w + r*Math.Cos(t));
ellipse.SetValue(Canvas.TopProperty, h + r*Math.Sin(t));
//ellipse.SetValue(Canvas.LeftProperty,w
// + Math.Sin(offset + posOffSet * step) * w);
//ellipse.SetValue(Canvas.TopProperty, h
// + Math.Cos(offset + posOffSet * step) * h);
}
示例8: InjectControl
public void InjectControl(FrameworkElement pControl)
{
_panel.Dispatcher.Invoke(() =>
{
pControl.SetValue(DockPanel.DockProperty, Dock.Left);
_panel.Children.Insert(1, pControl);
});
}
示例9: SetDefaultSource
public static void SetDefaultSource(FrameworkElement image, string value)
{
if (image == null)
{
throw new ArgumentNullException("Image");
}
image.SetValue(ImageDecoder.DefaultSourceProperty, value);
}
示例10: SetHasBeenStyled
private static void SetHasBeenStyled(FrameworkElement element, bool value)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
element.SetValue(HasBeenStyledProperty, value);
}
示例11: GetPushBindings
public static PushBindingCollection GetPushBindings(FrameworkElement obj)
{
if (obj.GetValue(PushBindingsProperty) == null)
{
obj.SetValue(PushBindingsProperty, new PushBindingCollection(obj));
}
return (PushBindingCollection)obj.GetValue(PushBindingsProperty);
}
示例12: SetIsConfigurable
/// <summary>
/// Sets the value of the IsConfigurable attached property to a specified FrameworkElement.
/// </summary>
/// <param name="element">The FrameworkElement to which the attached property is written.</param>
/// <param name="value">The needed IsConfigurable value.</param>
public static void SetIsConfigurable(FrameworkElement element, bool value)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
element.SetValue(IsConfigurableProperty, value);
}
示例13: SetFill
public static void SetFill(FrameworkElement element, bool value)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
element.SetValue(ZoomScrollViewer.FillProperty, value);
}
示例14: SetObserve
public static void SetObserve(FrameworkElement frameworkElement, bool observe)
{
if (frameworkElement == null)
{
throw new ArgumentNullException("frameworkElement");
}
frameworkElement.SetValue(ObserveProperty, observe);
}
示例15: SetObservedHeight
public static void SetObservedHeight(FrameworkElement frameworkElement, double observedHeight)
{
if (frameworkElement == null)
{
throw new ArgumentNullException("frameworkElement");
}
frameworkElement.SetValue(ObservedHeightProperty, observedHeight);
}