The size of the wpf control changes with the size of the form.

Source: Internet
Author: User

The size of the wpf control changes with the size of the form.

WPF can be implemented directly by setting the horizontal and vertical Alighment of the graphic controls to Stretch.
You can use a ViewBox to mount all the Window content and then zoom in and out together when the window is scaled.
The display mechanism of ViewBox is to display the sub-control according to the logical size in the memory, and then display the sub-control in proportional scaling to the customer area of ViewBox.

Example:

Button btn = new Button (); btn. HorizontalAlignment = System. Windows. HorizontalAlignment. Stretch; btn. verticalignment = System. Windows. verticalignment. Stretch;

Same implementation in xmal


All content in the window of WPF changes with the size of the window.

// Use ViewBox. ViewBox has a Stretch attribute, which is the same as the Image's Stretch attribute. The enumerated values are as follows:
// Keep the original size of the None content.
// Adjust the content size of Fill to Fill the target size. Do not retain the aspect ratio.
// Adjust the content size while retaining the original aspect ratio of the content to fit the target size.
// UniformToFill retains the original aspect ratio of the content and adjusts the content size to fill the target size. If the aspect ratio of the target rectangle is different from the aspect ratio of the source rectangle, the source content is cropped to fit the target size.
// ViewBox usage:
<Window>
<ViewBox Stretch = "Uniform">
<Grid> </Grid>
</ViewBox>
</Window>
// I hope my answer will help you.

C # wpf wants the control to change with the window size

Use expression blend to design the wpf front-end. feihonggang888 is feasible.

Related Article

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.