本文整理汇总了C#中System.Windows.UIElement.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.SetValue方法的具体用法?C# UIElement.SetValue怎么用?C# UIElement.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.UIElement
的用法示例。
在下文中一共展示了UIElement.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartAnimation
/// <summary>
/// Starts an animation to a particular value on the specified dependency property.
/// You can pass in an event handler to call when the animation has completed.
/// </summary>
public static void StartAnimation(UIElement animatableElement, DependencyProperty dependencyProperty, double toValue, double animationDurationSeconds, EventHandler completedEvent)
{
#if !SILVERLIGHT
double fromValue = (double)animatableElement.GetValue(dependencyProperty);
DoubleAnimation animation = new DoubleAnimation();
animation.From = fromValue;
animation.To = toValue;
animation.Duration = TimeSpan.FromSeconds(animationDurationSeconds);
animation.Completed += delegate(object sender, EventArgs e)
{
//
// When the animation has completed bake final value of the animation
// into the property.
//
animatableElement.SetValue(dependencyProperty, animatableElement.GetValue(dependencyProperty));
CancelAnimation(animatableElement, dependencyProperty);
if (completedEvent != null)
{
completedEvent(sender, e);
}
};
animation.Freeze();
animatableElement.BeginAnimation(dependencyProperty, animation);
#else
animatableElement.SetValue(dependencyProperty, toValue);
#endif
}
示例2: SetRegistration
public static void SetRegistration(UIElement element, CommandBindingCollection value)
{
if (element != null)
{
element.SetValue(Registration, value);
}
}
示例3: StartAnimation
/// <summary>
/// Starts an animation to a particular value on the specified dependency property.
/// You can pass in an event handler to call when the animation has completed.
/// </summary>
/// <param name="pAnimatableElement">The gui element to animate.</param>
/// <param name="pDependencyProperty">The dependency property to animate.</param>
/// <param name="pToValue">The final value of the dependency property.</param>
/// <param name="pAnimationDurationSeconds">The animation duration.</param>
/// <param name="pCompletedEvent">The callback executed when the animation ended.</param>
public static void StartAnimation(UIElement pAnimatableElement, DependencyProperty pDependencyProperty, double pToValue, double pAnimationDurationSeconds, EventHandler pCompletedEvent)
{
double lFromValue = (double)pAnimatableElement.GetValue(pDependencyProperty);
DoubleAnimation lAnimation = new DoubleAnimation();
lAnimation.From = lFromValue;
lAnimation.To = pToValue;
lAnimation.Duration = TimeSpan.FromSeconds(pAnimationDurationSeconds);
lAnimation.Completed += delegate(object pSender, EventArgs pEventArgs)
{
//
// When the animation has completed bake final value of the animation
// into the property.
//
pAnimatableElement.SetValue(pDependencyProperty, pAnimatableElement.GetValue(pDependencyProperty));
CancelAnimation(pAnimatableElement, pDependencyProperty);
if (pCompletedEvent != null)
{
pCompletedEvent(pSender, pEventArgs);
}
};
lAnimation.Freeze();
pAnimatableElement.BeginAnimation(pDependencyProperty, lAnimation);
}
示例4: SetCommand
/// <summary>
/// Sets the command property.
/// </summary>
/// <param name="element">The element.</param>
/// <param name="value">The value.</param>
public static void SetCommand(UIElement element, ICommand value)
{
if (element != null)
{
element.SetValue(CommandProperty, value);
}
}
示例5: StartAnimation
/// <summary>
/// Starts an animation to a particular value on the specified dependency property.
/// You can pass in an event handler to call when the animation has completed.
/// </summary>
public static void StartAnimation(UIElement animationElement, DependencyProperty dependencyProperty, double toValue, double animationDurationSeconds, EventHandler completedEvent)
{
if (animationElement == null)
{
throw new ArgumentNullResourceException("animationElement", Resources.General_Given_Parameter_Cannot_Be_Null);
}
var fromValue = (double)animationElement.GetValue(dependencyProperty);
var animation = new DoubleAnimation { From = fromValue, To = toValue, Duration = TimeSpan.FromSeconds(animationDurationSeconds) };
animation.Completed += (sender, e) =>
{
// When the animation has completed bake final value of the animation
// into the property.
animationElement.SetValue(dependencyProperty, animationElement.GetValue(dependencyProperty));
CancelAnimation(animationElement, dependencyProperty);
if (completedEvent != null)
{
completedEvent(sender, e);
}
};
animation.Freeze();
animationElement.BeginAnimation(dependencyProperty, animation);
}
示例6: SetIsEdit
public static void SetIsEdit(UIElement uiElement, bool value)
{
if (uiElement == null)
{
throw new ArgumentNullException("uiElement");
}
uiElement.SetValue(IsEditProperty, value);
}
示例7: SetSortDirection
public static void SetSortDirection(UIElement element, ListSortDirection? value)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
element.SetValue(SortDirectionProperty, value);
}
示例8: SetContextMenu
/// <summary>
/// Sets the value of the Menu attached property to a given DependencyObject.
/// </summary>
/// <param name="control">The element on which to set the property value.</param>
/// <param name="menu">The property value to set.</param>
public static void SetContextMenu(UIElement control, Menu menu)
{
// preconditions
Argument.IsNotNull("control", control);
// implementation
control.SetValue(ContextMenuProperty, menu);
}
示例9: SetInputBindings
public static void SetInputBindings( UIElement element, InputBindingCollection inputBindings )
{
element.SetValue( InputBindingsProperty, inputBindings );
}
示例10: SetParameter
public static void SetParameter(UIElement element, object parameter)
{
element.SetValue(OnParameterProperty, parameter);
}
示例11: SetDropDataType
public static void SetDropDataType(UIElement element, string type)
{
element.SetValue(DropDataTypeProperty, type);
}
示例12: SetIsMouseOverDispatcherTimer
private static void SetIsMouseOverDispatcherTimer(UIElement element, DispatcherTimer value)
{
element.SetValue(IsMouseOverDispatcherTimerProperty, value);
}
示例13: SetMouseScrollUp
public static void SetMouseScrollUp(UIElement element, ICommand value)
{
element.SetValue(MouseScrollUpProperty, value);
}
示例14: SetIgnoreIsMouseDown
public static void SetIgnoreIsMouseDown(UIElement element, bool value)
{
element.SetValue(IgnoreIsMouseDownProperty, value);
}
示例15: SetMagnifier
public static void SetMagnifier(UIElement element, Magnifier value)
{
element.SetValue(CurrentProperty, value);
}