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


C# UIElement.SetValue方法代码示例

本文整理汇总了C#中System.Windows.Controls.UIElement.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.SetValue方法的具体用法?C# UIElement.SetValue怎么用?C# UIElement.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.UIElement的用法示例。


在下文中一共展示了UIElement.SetValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetDock

        /// <summary>
        /// Writes the attached property Dock to the given element. 
        /// </summary>
        /// <param name="element">UIElement to which to write the attached property.</param> 
        /// <param name="dock">The property value to set</param> 
        /// <seealso cref="DockPanel.DockProperty" />
        public static void SetDock(UIElement element, Dock dock) 
        {
            if (element == null) { throw new ArgumentNullException("element"); }

            element.SetValue(DockProperty, dock); 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:12,代码来源:DockPanel.cs

示例2: SetLeft

 /// <summary>
 /// Writes the attached property Left to the given element.
 /// </summary>
 /// <param name="element">The element to which to write the Left attached property.</param>
 /// <param name="length">The length to set</param>
 /// <seealso cref="Canvas.LeftProperty" />
 public static void SetLeft(UIElement element, double length)
 {
     if (element == null) { throw new ArgumentNullException("element"); }
     element.SetValue(LeftProperty, length);
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:11,代码来源:Canvas.cs

示例3: PositiveValueValidation

		/*
        private static void PositiveValueValidation(DependencyObject d, DependencyPropertyChangedEventArgs e) 
        { 
            if ((int)e.NewValue <= 0)
            { 
                throw new ArgumentException(Resource.ToolTipService_SetTimeoutProperty_InvalidValue, "e");
            }
        } 
		 */
        private static void RegisterToolTip(UIElement owner, object toolTip)
        {
            Debug.Assert(owner != null, "ToolTip must have an owner");
            Debug.Assert(toolTip != null, "ToolTip can not be null"); 

            owner.MouseEnter += new MouseEventHandler(OnOwnerMouseEnter);
            owner.MouseLeave += new MouseEventHandler(OnOwnerMouseLeave); 
            owner.MouseLeftButtonDown += new MouseButtonEventHandler(OnOwnerMouseLeftButtonDown);
            owner.KeyDown += new KeyEventHandler(OnOwnerKeyDown);
            owner.SetValue (AssignedToolTipProperty, ConvertToToolTip(toolTip));
        } 
开发者ID:snorp,项目名称:moon,代码行数:20,代码来源:ToolTipService.cs

示例4: SetItemsHostInsetForChild

        private void SetItemsHostInsetForChild(int index, UIElement child, IContainItemStorage itemStorageProvider, bool isHorizontal)
        {
            Debug.Assert(!IsVSP45Compat, "SetItemsHostInset should not be called in VSP45-compat mode");

            // this only applies to a hierarchical element with a visible ItemsHost
            bool isChildHorizontal = isHorizontal;
            IHierarchicalVirtualizationAndScrollInfo virtualizingChild = GetVirtualizingChild(child, ref isChildHorizontal);
            Panel itemsHost = (virtualizingChild == null) ? null : virtualizingChild.ItemsHost;
            if (itemsHost == null || !itemsHost.IsVisible)
                return;

            // get the transformation from child coords to itemsHost coords
            GeneralTransform transform = child.TransformToDescendant(itemsHost);
            if (transform == null)
                return;     // when transform is undefined, ItemsHost is effectively invisible

            // build a rect (in child coords) describing the child's extended frame
            FrameworkElement fe = virtualizingChild as FrameworkElement;
            Thickness margin = (fe == null) ? new Thickness() : fe.Margin;
            Rect childRect = new Rect(new Point(), child.DesiredSize);
            childRect.Offset(-margin.Left, -margin.Top);

            // transform to itemsHost coords
            Rect itemsRect = transform.TransformBounds(childRect);

            // compute the desired inset, avoiding catastrophic cancellation errors
            Size itemsSize = itemsHost.DesiredSize;
            double left = DoubleUtil.AreClose(0, itemsRect.Left) ? 0 : -itemsRect.Left;
            double top = DoubleUtil.AreClose(0, itemsRect.Top) ? 0 : -itemsRect.Top;
            double right = DoubleUtil.AreClose(itemsSize.Width, itemsRect.Right) ? 0 : itemsRect.Right-itemsSize.Width;
            double bottom = DoubleUtil.AreClose(itemsSize.Height, itemsRect.Bottom) ? 0 : itemsRect.Bottom-itemsSize.Height;
            Thickness inset = new Thickness(left, top, right, bottom);


            // get the item to use as the key into items storage
            object item = GetItemFromContainer(child);
            if (item == DependencyProperty.UnsetValue)
            {
                Debug.Assert(false, "SetInset should only be called for a container");
                return;
            }

            // see whether inset is changing
            object box = itemStorageProvider.ReadItemValue(item, ItemsHostInsetProperty);
            bool changed = (box == null);
            bool remeasure = changed;
            if (!changed)
            {
                Thickness oldInset = (Thickness)box;
                changed = !(    DoubleUtil.AreClose(oldInset.Left, inset.Left) &&
                                DoubleUtil.AreClose(oldInset.Top, inset.Top ) &&
                                DoubleUtil.AreClose(oldInset.Right, inset.Right) &&
                                DoubleUtil.AreClose(oldInset.Bottom, inset.Bottom) );

                // only changes along the scrolling axis require a remeasure.
                // use a less stringent "AreClose" test;  experiments show that the
                // trailing inset can change due to roundoff error by an amount
                // that is larger than the tolerance in DoubleUtil, but not large
                // enough to warrant an expensive remeasure.
                remeasure = changed &&
                    (   (isHorizontal  && !(AreInsetsClose(oldInset.Left, inset.Left) &&
                                            AreInsetsClose(oldInset.Right, inset.Right)))
                     || (!isHorizontal && !(AreInsetsClose(oldInset.Top, inset.Top) &&
                                            AreInsetsClose(oldInset.Bottom, inset.Bottom))) );
            }

            if (changed)
            {
                // store the new inset
                itemStorageProvider.StoreItemValue(item, ItemsHostInsetProperty, inset);
                child.SetValue(ItemsHostInsetProperty, inset);
            }

            if (remeasure)
            {
                // re-measure the scrolling panel
                ItemsControl scrollingItemsControl = GetScrollingItemsControl(child);
                Panel scrollingPanel = (scrollingItemsControl == null) ? null : scrollingItemsControl.ItemsHost;
                if (scrollingPanel != null)
                {
                    VirtualizingStackPanel vsp = scrollingPanel as VirtualizingStackPanel;
                    if (vsp != null)
                    {
                        vsp.AnchoredInvalidateMeasure();
                    }
                    else
                    {
                        scrollingPanel.InvalidateMeasure();
                    }
                }
            }
        }
开发者ID:mind0n,项目名称:hive,代码行数:92,代码来源:VirtualizingStackPanel.cs

示例5: SetZIndex

        /// <summary>
        /// Helper for setting ZIndex property on a UIElement. 
        /// </summary>
        /// <param name="element">UIElement to set ZIndex property on.</param>
        /// <param name="value">ZIndex property value.</param>
        public static void SetZIndex(UIElement element, int value) 
        {
            if (element == null) 
            { 
                throw new ArgumentNullException("element");
            } 

            element.SetValue(ZIndexProperty, value);
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:14,代码来源:panel.cs

示例6: SetTop

		public static void SetTop (UIElement ctrl, float value) {
			ctrl.SetValue (TopProperty, value);
        }
开发者ID:bbqchickenrobot,项目名称:WPFLight,代码行数:3,代码来源:Canvas.cs

示例7: SetLeft

		public static void SetLeft ( UIElement ctrl, float value ) {
			ctrl.SetValue (LeftProperty, value);
		}
开发者ID:bbqchickenrobot,项目名称:WPFLight,代码行数:3,代码来源:Canvas.cs

示例8: SetColumnSpan

		public static void SetColumnSpan (UIElement item, int columnSpan) {
			item.SetValue (ColumnSpanProperty, columnSpan);
		}
开发者ID:bbqchickenrobot,项目名称:WPFLight,代码行数:3,代码来源:Grid.cs

示例9: SetRowSpan

		public static void SetRowSpan (UIElement item, int rowSpan) {
			item.SetValue (RowSpanProperty, rowSpan);
		}
开发者ID:bbqchickenrobot,项目名称:WPFLight,代码行数:3,代码来源:Grid.cs

示例10: SetRow

		public static void SetRow (UIElement item, int row) {
			item.SetValue (RowProperty, row);
		}
开发者ID:bbqchickenrobot,项目名称:WPFLight,代码行数:3,代码来源:Grid.cs


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