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


C# UIElement.UpdateLayout方法代码示例

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


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

示例1: DisableSizeToContent

        private void DisableSizeToContent(UIElement rootUIElement, IntPtr hwnd)
        {
            if (_sizeToContent != SizeToContent.Manual)
            {
                _sizeToContent = SizeToContent.Manual;

                // hamidm - 10/27/2005
                // 1348020 Window expereience layout issue when SizeToContent is being turned
                // off by user interaction
                // This bug was caused b/c we were giving rootUIElement.DesiredSize as input
                // to Measure/Arrange below.  That is incorrect since rootUIElement.DesiredSize may not
                // cover the entire hwnd client area.

                // GetSizeFromHwnd returns either the outside size or the client size of the hwnd based on
                // _adjustSizeingForNonClientArea flag in logical units.
                Size sizeLogicalUnits = GetSizeFromHwnd();
                rootUIElement.Measure(sizeLogicalUnits);
                rootUIElement.Arrange(new Rect(new Point(), sizeLogicalUnits));

                rootUIElement.UpdateLayout(); //finalizes layout


                if (SizeToContentChanged != null)
                {
                    SizeToContentChanged(this, EventArgs.Empty);
                }
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:28,代码来源:HwndSource.cs

示例2: Forward

        // Forward to the next element
        void Forward(UIElement element, bool click)
        {
            Detach();
            if (click)
            {
                element.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, null));
                element.UpdateLayout();
            }

            UIElement[] children = LogicalTreeHelper.GetChildren(element)
                .Cast<object>()
                .Where(x => x is UIElement)
                .Cast<UIElement>().ToArray();
            if (children.Length == 0) { Terminate(); return; }
                    
            childAdorner = GetTopLevelElement(children[0]) != GetTopLevelElement(element) ? 
                new KeyTipAdorner(children[0], element, this) :
                new KeyTipAdorner(element, element, this);

            if (childAdorner.keyTips.Count != 0)
            {
                Detach();
                childAdorner.Attach();
            }
            else
            {
                Terminate();
            }
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:30,代码来源:KeyTipAdorner.cs

示例3: Process_WM_SIZE

        private void Process_WM_SIZE(UIElement rootUIElement, IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam)
        {
            int x = NativeMethods.SignedLOWORD(lParam);
            int y = NativeMethods.SignedHIWORD(lParam);
            Point pt = new Point(x, y);
            const EventTrace.Keyword etwKeywords = EventTrace.Keyword.KeywordLayout | EventTrace.Keyword.KeywordPerf;
            bool etwEnabled = EventTrace.IsEnabled(etwKeywords, EventTrace.Level.Info);
            long ctxHashCode = 0;

            // 1. If it's coming from Layout (_myOwnUpdate), it means we are adjusting
            // to the right size; don't need to do anything here.
            // 2. If SizeToContent is set to WidthAndHeight, then we maintain the current hwnd size
            // in WM_WINDOWPOSCHANGING, so we don't need to re-layout here.  If SizeToContent
            // is set to Width or Height and developer calls SetWindowPos to set a new
            // Width/Height, we need to do a layout.
            // 3. We also don't need to do anything if it's minimized.

            // Keeps the status of whether the Window is in Minimized state or not.
            _isWindowInMinimizeState = (NativeMethods.IntPtrToInt32(wParam) == NativeMethods.SIZE_MINIMIZED) ? true : false;

            if ((!_myOwnUpdate) && (_sizeToContent != SizeToContent.WidthAndHeight) && !_isWindowInMinimizeState)
            {
                Point relevantPt = new Point(pt.X, pt.Y);

                // WM_SIZE has the client size of the window.
                // for appmodel window case, get the outside size of the hwnd.
                if (_adjustSizingForNonClientArea == true)
                {
                    NativeMethods.RECT rect = new NativeMethods.RECT(0, 0, (int)pt.X, (int)pt.Y);
                    GetNonClientRect(ref rect);
                    relevantPt.X = rect.Width;
                    relevantPt.Y = rect.Height;
                }

                // The lParam/wParam size and the GetNonClientRect size are
                // both in device coordinates, thus we convert to Measure
                // coordinates here.
                relevantPt = TransformFromDevice(relevantPt);

                Size sz = new Size(
                    (_sizeToContent == SizeToContent.Width ? double.PositiveInfinity : relevantPt.X),
                    (_sizeToContent == SizeToContent.Height ? double.PositiveInfinity : relevantPt.Y));

                // NOTE: hamidm -- 6/03/04
                // 962884 Avalon content does not resize when the favorites
                // (or other side pane) is closed
                //
                // The issue is that when the browser shows favorites window, avalon
                // window is resized and we get WM_SIZE.  Here, we pass the IE window's
                // size to Measure so that Computed[Width/Height] gets the correct
                // IE window dimensions.  Since, IE window's size may not change, the
                // call to Measure is optimized out and no layout happens.  Invalidating
                // layout here ensures that we do layout.
                // This can happen only in the Window case
                if (_adjustSizingForNonClientArea == true)
                {
                    rootUIElement.InvalidateMeasure();
                }

                if (etwEnabled)
                {
                    ctxHashCode = _hwndWrapper.Handle.ToInt64();
                    EventTrace.EventProvider.TraceEvent(EventTrace.Event.WClientLayoutBegin, etwKeywords, EventTrace.Level.Info, ctxHashCode, EventTrace.LayoutSource.HwndSource_WMSIZE);
                    EventTrace.EventProvider.TraceEvent(EventTrace.Event.WClientMeasureBegin, etwKeywords, EventTrace.Level.Info, ctxHashCode);;
                }

                rootUIElement.Measure(sz);

                if (_sizeToContent == SizeToContent.Width) sz = new Size(rootUIElement.DesiredSize.Width, relevantPt.Y);
                else if (_sizeToContent == SizeToContent.Height) sz = new Size(relevantPt.X, rootUIElement.DesiredSize.Height);
                else sz = new Size(relevantPt.X, relevantPt.Y);

                if (etwEnabled)
                {
                    EventTrace.EventProvider.TraceEvent(EventTrace.Event.WClientMeasureEnd, etwKeywords, EventTrace.Level.Info, 1);
                    EventTrace.EventProvider.TraceEvent(EventTrace.Event.WClientArrangeBegin, etwKeywords, EventTrace.Level.Info, ctxHashCode);
                }

                rootUIElement.Arrange(new Rect(new Point(), sz));

                if (etwEnabled)
                {
                    EventTrace.EventProvider.TraceEvent(EventTrace.Event.WClientArrangeEnd, etwKeywords, EventTrace.Level.Info, 1);
                    EventTrace.EventProvider.TraceEvent(EventTrace.Event.WClientLayoutEnd, etwKeywords, EventTrace.Level.Info);
                }
                rootUIElement.UpdateLayout(); //finalizes layout

            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:89,代码来源:HwndSource.cs

示例4: ExpandPathToNodeAndSelectBestMatchRecursively

        private static object ExpandPathToNodeAndSelectBestMatchRecursively(UIElement treeView, ItemContainerGenerator owningItemGenerator, object currentNodeDataItem, Func<object, IEnumerable> childNodeDataItemSelector, Func<object, string, int, bool> matchPathToNode, string[] pathTokens, int tokenIndex)
        {
            var foundNode = default(object);
            var currentToken = pathTokens[tokenIndex];

            // Check whether this is the node we are looking for.
            if ((matchPathToNode(currentNodeDataItem, currentToken, tokenIndex)))
            {
                // Expand this item before looking at the children. The update layout call is needed because although the
                // item has been expanded, none of the expanded items will have been created, and so calls to the
                // treeViewItem.ItemGenerator will return null until the UI has had a chance to create the child items.
                var currentTreeViewItem = ExpandTreeViewItem(owningItemGenerator, currentNodeDataItem);
                if (treeView != null)
                {
                    treeView.UpdateLayout();
                }

                if (tokenIndex < pathTokens.Length - 1)
                {
                    // Now see if we can continue to match any of the children.
                    var currentChildItemCenerator = currentTreeViewItem == null ? null : currentTreeViewItem.ItemContainerGenerator;
                    var childNodes = childNodeDataItemSelector(currentNodeDataItem);
                    if (childNodes != null)
                    {
                        foreach (var childNode in childNodes)
                        {
                            foundNode = ExpandPathToNodeAndSelectBestMatchRecursively(treeView, currentChildItemCenerator, childNode, childNodeDataItemSelector, matchPathToNode, pathTokens, tokenIndex + 1);
                            if (foundNode != null)
                            {
                                break;
                            }
                        }
                    }
                }

                // This node is a match, but none of the children are (or there are no children). Select this node instead.
                if (foundNode == null)
                {
                    foundNode = currentNodeDataItem;
                    SelectTreeViewItem(owningItemGenerator, currentNodeDataItem);
                }
            }
            return foundNode;
        }
开发者ID:PaulStovell,项目名称:bindable,代码行数:44,代码来源:TreeViewHelper.cs


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