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


C# UIElement.InvalidateMeasure方法代码示例

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


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

示例1: InvalidateMeasureRecursive

        private static void InvalidateMeasureRecursive(UIElement element)
        {
            if (element == null)
            {
                return;
            }

            element.InvalidateMeasure();

            for (var i = 0; i < VisualTreeHelper.GetChildrenCount(element); i++)
            {
                var child = VisualTreeHelper.GetChild(element, i) as UIElement;

                if (child == null)
                {
                    continue;
                }

                InvalidateMeasureRecursive(child);
            }
        }
开发者ID:maurosampietro,项目名称:Fluent.Ribbon,代码行数:21,代码来源:RibbonGroupBox.cs

示例2: InvalidateMeasureRecursive

 static void InvalidateMeasureRecursive(UIElement element)
 {
     if (element == null) return;
     element.InvalidateMeasure();
     for (int i = 0; i < VisualTreeHelper.GetChildrenCount(element); i++)
     {
         InvalidateMeasureRecursive(VisualTreeHelper.GetChild(element, i) as UIElement);
     }
 }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:9,代码来源:RibbonGroupBox.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: InvalidateMeasureRecursive

        static void InvalidateMeasureRecursive(UIElement visual)
        {
            visual.InvalidateMeasure();

            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(visual); i++)
            {
                UIElement element = VisualTreeHelper.GetChild(visual, i) as UIElement;
                if (element != null) InvalidateMeasureRecursive(element);
            }
        }
开发者ID:rad1oactive,项目名称:BetterExplorer,代码行数:10,代码来源:GalleryPanel.cs

示例5: MeasureContainer

    private void MeasureContainer( UIElement container )
    {
      DataGridContext dataGridContext = DataGridControl.GetDataGridContext( container );

      string dataGridContextName = this.GetDataGridContextName( container, dataGridContext );
      bool containerIsRow = this.ContainerIsRow( container );

      if( !m_autoWidthCalculatedDataGridContextList.Contains( dataGridContextName )
        && containerIsRow )
      {
        dataGridContext.ColumnStretchingManager.ColumnStretchingCalculated = false;

        // Calling Measure with the Viewport's width will have the effect of 
        // distributing the extra space (see FixedCellPanel's MeasureOverride). 
        // Eventually, the FixedCellPanel will receive an adjusted viewport 
        // width (where GroupLevelIndicator's width et al will be substracted).
        container.Measure( new Size( m_lastMeasureAvailableSize.Width, m_containerHeight ) );

        if( dataGridContext.ColumnStretchingManager.ColumnStretchingCalculated )
        {
          // We only calculate once per detail.
          m_autoWidthCalculatedDataGridContextList.Add( dataGridContextName );
        }
      }
      else
      {
        // We invalidate the CellsHostPanel of the row and all is parent to ensure the
        // size is correctly evaluated when we have some auto stretching column.
        container.InvalidateMeasure();

        Row row = Row.FromContainer( container );
        if( row != null )
        {
          UIElement itemToInvalidate = row.CellsHostPanel;

          while( ( itemToInvalidate != null ) && ( itemToInvalidate != container ) )
          {
            itemToInvalidate.InvalidateMeasure();
            itemToInvalidate = VisualTreeHelper.GetParent( itemToInvalidate ) as UIElement;
          }
        }
      }

      // We always measure the container with infinity so that we'll arrange each container,
      // for a DataGridContext, with the maximum needed for that context.
      container.Measure( new Size( double.PositiveInfinity, m_containerHeight ) );

      double desiredSize = container.DesiredSize.Width;
      double cachedSize;

      if( m_cachedContainerDesiredWidth.TryGetValue( dataGridContextName, out cachedSize ) )
      {
        // Keep the largest size!
        if( cachedSize < desiredSize )
        {
          m_cachedContainerDesiredWidth[ dataGridContextName ] = desiredSize;
        }
      }
      else
      {
        // Cache the size for the context.
        m_cachedContainerDesiredWidth.Add( dataGridContextName, desiredSize );
      }

      PassiveLayoutDecorator decorator = this.GetPassiveLayoutDecorator( container as HeaderFooterItem );
      if( decorator != null )
      {
        desiredSize = decorator.RealDesiredSize.Width;

        if( m_cachedContainerRealDesiredWidth.TryGetValue( dataGridContextName, out cachedSize ) )
        {
          // Keep the largest size!
          if( cachedSize < desiredSize )
          {
            m_cachedContainerRealDesiredWidth[ dataGridContextName ] = desiredSize;
          }
        }
        else
        {
          // Cache the size for the context.
          m_cachedContainerRealDesiredWidth.Add( dataGridContextName, desiredSize );
        }
      }
    }
开发者ID:austinedeveloper,项目名称:WpfExtendedToolkit,代码行数:84,代码来源:TableflowViewItemsHost.cs

示例6: InvalidateMeasureRecursively

        /// <summary>
        /// Recursively invalidates the measurement state of the
        /// specified element and all of its descendants.
        /// </summary>
        private static void InvalidateMeasureRecursively(UIElement element)
        {
            element.InvalidateMeasure();

            VisualTreeHelper.ForEachChild(element, null, (child, state) =>
            {
                InvalidateMeasureRecursively((UIElement)child);
            });
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:13,代码来源:PopupRoot.cs


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