WPF is in close contact with the Surface 2.0 SDK-graphic Scaling

Source: Internet
Author: User

Through the previous introduction, we should have learned that ScatterView allows developers to conveniently implement Manipulate operations on controls. Careful friends may find that there seems to be some problems with rectangular scaling in the previous example. To facilitate the description, we compile the following code.

<Grid>    <s:ScatterView>        <Rectangle Fill="Blue" Width="200" Height="100"/>        <Ellipse Fill="Red" Width="150" Height="80"/>    </s:ScatterView></Grid>

Rectangular and elliptical shapes are added to the ScatterView, and the length and width of the two images are not limited. When scaling the image, we found that the size of the two images has not changed, but the size of the ScatterViewItem has increased. It seems that the image size is limited by the length and width parameters.

In this case, you need to use the Viewbox control. Viewbox is not a Surface 2.0 SDK control, but a WPF control. It allows the image to change with the size of ScatterViewItem. The following sample code creates two identical Rectangles and embeds only one of them into the Viewbox control. The red rectangle in the Viewbox is automatically adjusted according to the size change of ScatterViewItem. In this way, when we perform the Manipulate operation, the size of the corresponding control will also change.

<Grid>    <s:ScatterView>        <Rectangle Fill="Blue" Width="200" Height="100"/>        <Viewbox>            <Rectangle Fill="Red" Width="200" Height="100"/>        </Viewbox>    </s:ScatterView></Grid>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.