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

Arrange() public method

public Arrange ( RectangleF finalRect ) : void
finalRect RectangleF
return void
        public void Arrange(RectangleF finalRect)
        {
            if (finalRect.IsEmpty)
                throw new InvalidOperationException ("Empty Rect");

            if (Double.IsInfinity (finalRect.Width) || Double.IsInfinity (finalRect.Height) || Double.IsInfinity (finalRect.X) || Double.IsInfinity (finalRect.Y))
                throw new InvalidOperationException ("Infinite Rect");
            if (Double.IsNaN (finalRect.Width) || Double.IsNaN (finalRect.Height) || Double.IsNaN (finalRect.X) || Double.IsNaN (finalRect.Y))
                throw new InvalidOperationException ("NaN Rect");

            NativeMethods.uielement_arrange(native, finalRect);
        }

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::Arrange