The System.Windows.Controls.Canvas Arrange method is used to arrange the child elements of the canvas within the specified layout. The method takes in a Rect object which specifies the size and position of the canvas, and then arranges the child elements according to the specified layout.
Example 1: Canvas canvas = new Canvas(); canvas.Children.Add(new Button()); canvas.Arrange(new Rect(0, 0, 100, 100));
In this example, a Canvas object is created and a child Button element is added to it. The Arrange method is then called, specifying a Rect object with a size of 100x100 pixels. This will arrange the child Button element within the canvas with a size of 100x100 pixels.
Example 2: Canvas canvas = new Canvas(); Button button = new Button(); canvas.Children.Add(button); Canvas.SetLeft(button, 10); Canvas.SetTop(button, 10); canvas.Arrange(new Rect(0, 0, 100, 100));
In this example, a Canvas object is created and a child Button element is added to it. Then, the Canvas.SetLeft and Canvas.SetTop methods are called to set the position of the Button element to (10, 10) within the canvas. The Arrange method is then called, which will arrange the child Button element within the canvas with a size of 100x100 pixels.
The package library for this method is the System.Windows.Controls namespace in the WindowsBase.dll assembly.
C# (CSharp) System.Windows.Controls Canvas.Arrange - 32 examples found. These are the top rated real world C# (CSharp) examples of System.Windows.Controls.Canvas.Arrange extracted from open source projects. You can rate examples to help us improve the quality of examples.