System.Windows.UIElement.Measure C# (CSharp) Method

Measure() public method

public Measure ( Size availableSize ) : void
availableSize Size
return void
        public void Measure(Size availableSize)
        {
            NativeMethods.uielement_measure (native, availableSize);
        }

Usage Example

		private static BitmapSource CreateElementScreenshot(UIElement uiElement)
		{
			bool measureValid = uiElement.IsMeasureValid;

			if (!measureValid)
			{
				double width = 300;
				double height = 300;

				FrameworkElement frElement = uiElement as FrameworkElement;
				if (frElement != null)
				{
					if (!Double.IsNaN(frElement.Width))
						width = frElement.Width;
					if (!Double.IsNaN(frElement.Height))
						height = frElement.Height;
				}

				Size size = new Size(width, height);
				uiElement.Measure(size);
				uiElement.Arrange(new Rect(size));
			}

			RenderTargetBitmap bmp = new RenderTargetBitmap(
				(int)uiElement.RenderSize.Width, (int)uiElement.RenderSize.Height,
				96, 96, PixelFormats.Default);

			// this is waiting for dispatcher to perform measure, arrange and render passes
			uiElement.Dispatcher.Invoke(((Action)(() => { })), DispatcherPriority.Background);

			bmp.Render(uiElement);

			return bmp;
		}
All Usage Examples Of System.Windows.UIElement::Measure