![]() A RectangleGeometry defines a rectangle for the area of the image that will be displayed. In this example, we define an Image object with a height of 200. The next example shows how to use a RectangleGeometry as the clip region for an image. Currently, non-rectangular clipping is not supported. You can use the Clip property to clip an area from the image output. ![]() That is, the image might be distorted to completely fill the output area. Because the content's height and width are scaled independently, the original aspect ratio of the image might not be preserved. Fill: The image is scaled to fit the output dimensions.UniformToFill: The image is scaled so that it completely fills the output area but preserves its original aspect ratio.But the aspect ratio of the content is preserved. Uniform: The image is scaled to fit the output dimensions.Be careful with this Stretch setting: if the source image is larger than the containing area, your image will be clipped, and this usually isn't desirable because you don't have any control over the viewport like you do with a deliberate Clip. None: The image doesn't stretch to fill the output dimensions.The Stretch property accepts these values, which the Stretch enumeration defines: You can specify how the image fills this containing area by using the Stretch property. Setting the Width and Height creates a containing rectangular area in which the image is displayed. ![]() If you don't set the Width or Height values of an Image, it is displayed with the dimensions of the image specified by the Source. Here's the Ellipse painted by the ImageBrush. The next example shows how to use an ImageBrush to paint an Ellipse. For example, you can use an ImageBrush for the value of the Fill property of an Ellipse or the Background property of a Canvas. With the ImageBrush object, you can use an image to paint an area that takes a Brush object. For our example, we put the "sunset.jpg" image file in the root folder of our project and declare project settings that include the image file as content. You can set the Source by specifying an absolute URL (for example, ) or by specifying a URL that is relative to your app packaging structure. In this example, the Source property specifies the location of the image that you want to display. This example shows how to create an image by using the Image object. Get the app from the Microsoft Store or get the source code on GitHub Image The WinUI 3 Gallery app includes interactive examples of most WinUI 3 controls, features, and functionality. Open the WinUI 3 Gallery app and see ImageBrushes in action.
0 Comments
Leave a Reply. |