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


C# DependencyObject.SetValue方法代码示例

本文整理汇总了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;
        }
开发者ID:HimanshPal,项目名称:Cimbalino-Toolkit,代码行数:35,代码来源:MonitoredInteraction.cs

示例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);
     }
 }
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:12,代码来源:ViewModelLocator.cs

示例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;
 }
开发者ID:ruisebastiao,项目名称:DevExpress.Mvvm.Free,代码行数:8,代码来源:Interaction.cs

示例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;
 }
开发者ID:ruisebastiao,项目名称:DevExpress.Mvvm.Free,代码行数:8,代码来源:Interaction.cs

示例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);
 }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:14,代码来源:DataGridFrozenGrid.cs

示例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);
        }
开发者ID:lecode-official,项目名称:mvvm-framework,代码行数:13,代码来源:ScrollViewer.cs

示例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);
        }
开发者ID:lecode-official,项目名称:mvvm-framework,代码行数:13,代码来源:ComboBox.cs

示例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);
        }
开发者ID:lecode-official,项目名称:mvvm-framework,代码行数:13,代码来源:UIElement.cs

示例9: SetPlacement

        public static void SetPlacement(DependencyObject element, PlacementMode value)
        {
            if (element == null) 
            {
                throw new ArgumentNullException("element");
            } 
 
            element.SetValue(ToolTipService.PlacementProperty, value);
        } 
开发者ID:kangaroo,项目名称:moon,代码行数:9,代码来源:ToolTipService.cs

示例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);
        }
开发者ID:xperiandri,项目名称:PortablePrism,代码行数:14,代码来源:ClearChildViewsRegionBehavior.cs

示例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);
        }
开发者ID:lecode-official,项目名称:mvvm-framework,代码行数:14,代码来源:Control.cs

示例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);
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:12,代码来源:AutomationProperties.cs

示例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);
        }
开发者ID:JulianMH,项目名称:music-3,代码行数:14,代码来源:MenuFlyoutService.cs

示例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); 
        }
开发者ID:dfr0,项目名称:moon,代码行数:17,代码来源:KeyboardNavigation.cs

示例15: SetWorkflowDefinitionLockObject

 internal static void SetWorkflowDefinitionLockObject(DependencyObject dependencyObject, object value)
 {
     lock (dependencyObject)
     {
         if (dependencyObject.GetValue(WorkflowDefinitionLockObjectProperty) == null)
         {
             dependencyObject.SetValue(WorkflowDefinitionLockObjectProperty, value);
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:WorkflowDefinitionLock.cs


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