本文整理汇总了C#中DependencyObject.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject.SetValue方法的具体用法?C# DependencyObject.SetValue怎么用?C# DependencyObject.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DependencyObject
的用法示例。
在下文中一共展示了DependencyObject.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBehaviors
/// <summary>
/// Gets the <see cref="BehaviorCollection"/> associated with a specified object.
/// </summary>
/// <param name="obj">The object from which to retrieve the <see cref="BehaviorCollection"/>.</param>
/// <returns>A <see cref="BehaviorCollection"/> containing the behaviors associated with the specified object.</returns>
public static BehaviorCollection GetBehaviors(DependencyObject obj)
{
var behaviorCollection = (BehaviorCollection)obj.GetValue(BehaviorsProperty);
if (behaviorCollection == null)
{
#if WINDOWS_PHONE
behaviorCollection = (BehaviorCollection)typeof(BehaviorCollection)
.GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, null)
.Invoke(null);
#else
behaviorCollection = new BehaviorCollection();
#endif
obj.SetValue(BehaviorsProperty, behaviorCollection);
obj.SetValue(Interaction.BehaviorsProperty, behaviorCollection);
var frameworkElement = obj as FrameworkElement;
if (frameworkElement != null)
{
frameworkElement.Loaded -= FrameworkElement_Loaded;
frameworkElement.Loaded += FrameworkElement_Loaded;
frameworkElement.Unloaded -= FrameworkElement_Unloaded;
frameworkElement.Unloaded += FrameworkElement_Unloaded;
}
}
return behaviorCollection;
}
示例2: SetAutoWireViewModel
/// <summary>
/// Sets the value of the AutoWireViewModel attached property.
/// </summary>
/// <param name="obj">The dependency object that has this attached property.</param>
/// <param name="value">if set to <c>true</c> the view model wiring will be performed.</param>
public static void SetAutoWireViewModel(DependencyObject obj, bool value)
{
if (obj != null)
{
obj.SetValue(AutoWireViewModelProperty, value);
}
}
示例3: GetTriggers
public static TriggerCollection GetTriggers(DependencyObject d) {
TriggerCollection triggers = (TriggerCollection)d.GetValue(TriggersProperty);
if(triggers == null) {
triggers = new TriggerCollection();
d.SetValue(TriggersProperty, triggers);
}
return triggers;
}
示例4: GetBehaviors
public static BehaviorCollection GetBehaviors(DependencyObject d) {
BehaviorCollection behaviors = (BehaviorCollection)d.GetValue(BehaviorsProperty);
if(behaviors == null) {
behaviors = new BehaviorCollection();
d.SetValue(BehaviorsProperty, behaviors);
}
return behaviors;
}
示例5: SetIsFrozen
/// <summary>
/// Sets a value that indicates whether the grid is frozen.
/// </summary>
/// <param name="element">The object to set the <see cref="P:System.Windows.Controls.Primitives.DataGridFrozenGrid.IsFrozen" /> value on.</param>
/// <param name="value">true if <paramref name="element" /> is frozen; otherwise, false.</param>
/// <exception cref="T:System.ArgumentNullException"><paramref name="element" /> is null.</exception>
public static void SetIsFrozen(DependencyObject element, bool value)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
element.SetValue(IsFrozenProperty, value);
}
示例6: SetIsHorizontalScrollingEnabled
/// <summary>
/// Sets the value of the <see cref="IsHorizontalScrollingEnabledProperty"/> attached property.
/// </summary>
/// <param name="scrollViewer">The scroll viewer which is used to set the value.</param>
/// <param name="value">The value that is to be set.</param>
public static void SetIsHorizontalScrollingEnabled(DependencyObject scrollViewer, bool value)
{
// Validates the parameters
if (scrollViewer == null)
throw new ArgumentNullException(nameof(scrollViewer));
scrollViewer.SetValue(ScrollViewer.IsHorizontalScrollingEnabledProperty, value);
}
示例7: SetValueRegex
/// <summary>
/// Sets the value of the <see cref="ValueRegexProperty"/> attached property.
/// </summary>
/// <param name="frameworkElement">The framework element which is used to set the value.</param>
/// <param name="value">The value that is to be set.</param>
public static void SetValueRegex(DependencyObject frameworkElement, string value)
{
// Validates the argument
if (frameworkElement == null)
throw new ArgumentNullException(nameof(frameworkElement));
frameworkElement.SetValue(ComboBox.ValueRegexProperty, value);
}
示例8: SetInputBindings
/// <summary>
/// Sets the value of the <see cref="InputBindingsProperty"/> attached property.
/// </summary>
/// <param name="uiElement">The UI element which is used to set the value.</param>
/// <param name="value">The value that is to be set.</param>
public static void SetInputBindings(DependencyObject uiElement, ICommand value)
{
// Validates the argument
if (uiElement == null)
throw new ArgumentNullException(nameof(uiElement));
uiElement.SetValue(UIElement.InputBindingsProperty, value);
}
示例9: SetPlacement
public static void SetPlacement(DependencyObject element, PlacementMode value)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
element.SetValue(ToolTipService.PlacementProperty, value);
}
示例10: SetClearChildViews
/// <summary>
/// Sets the ClearChildViews attached property in a DependencyObject.
/// </summary>
/// <param name="target">The object in which to set the value.</param>
/// <param name="value">The value of to set in the target object's ClearChildViews attached property.</param>
public static void SetClearChildViews(DependencyObject target, bool value)
{
if (target == null)
{
throw new ArgumentNullException("target");
}
target.SetValue(ClearChildViewsRegionBehavior.ClearChildViewsProperty, value);
}
示例11: SetHasFocus
/// <summary>
/// Sets a value that determines whether the control to which the <see cref="HasFocusProperty"/> attached property has been attached, currently has the focus.
/// </summary>
/// <param name="control">The control whose <see cref="HasFocusProperty"/> is to be set.</param>
/// <param name="value">The new value for the <see cref="HasFocusProperty"/>. If the value is <c>true</c>, then the control is focused, otherwise the focus is move to the next control.</param>
public static void SetHasFocus(DependencyObject control, bool value)
{
// Validates the parameters
if (control == null)
throw new ArgumentNullException(nameof(control));
// Sets the value of the attached property
control.SetValue(Control.HasFocusProperty, value);
}
示例12: SetName
/// <summary>
/// Helper for setting Name property on a DependencyObject.
/// </summary>
public static void SetName(DependencyObject element, string value)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
element.SetValue(NameProperty, value);
}
示例13: SetMenuFlyout
/// <summary>
/// Sets the value of the MenuFlyout property of the specified object.
/// </summary>
/// <param name="element">Object to set the property on.</param>
/// <param name="value">Value to set.</param>
public static void SetMenuFlyout(DependencyObject element, MenuFlyout value)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
element.SetValue(MenuFlyoutProperty, value);
}
示例14: SetAcceptsReturn
/// <summary>
/// Sets the value of the AcceptsReturn attached property for the
/// specified element.
/// </summary>
/// <param name="element">
/// The element to write the attached property to.
/// </param>
/// <param name="enabled">The property value to set.</param>
public static void SetAcceptsReturn(DependencyObject element, bool enabled)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
element.SetValue(AcceptsReturnProperty, enabled);
}
示例15: SetWorkflowDefinitionLockObject
internal static void SetWorkflowDefinitionLockObject(DependencyObject dependencyObject, object value)
{
lock (dependencyObject)
{
if (dependencyObject.GetValue(WorkflowDefinitionLockObjectProperty) == null)
{
dependencyObject.SetValue(WorkflowDefinitionLockObjectProperty, value);
}
}
}