WPF automatically adapts to screens based on different screen resolutions

Source: Internet
Author: User
problem0 Login to vote

The interface layout is by default 1920*1080 resolution layout, now want to automatically adapt to different resolutions of the screen.

such as TextBlock width 100 high 40 text is 20px

Adapt to the resolution for 1600*900, what to do to make TextBlock look unchanged

Thank you May 7, 2014 2:46 reply | Quote Answer 1 login to vote

Can you consider view Box? As long as the fixed value of the design layout, put in a fixed-width canvas/grid, and then put into the viewbox, you can ensure that all of your control a wide scale unchanged.

Changing the size of the window, the controls inside will adapt to change.

<window x:class= "Wpfapplication4.mainwindow"
        xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/ Presentation "
        xmlns:x=" Http://schemas.microsoft.com/winfx/2006/xaml "
        title=" MainWindow "height=" "350" Width= "525" >
    <Viewbox>
        <canvas height= "1080" width= "1920" >
            <textblock text= " Something "canvas.left=" 900 "canvas.top=" fontsize= ""/>
        </Canvas>
    </Viewbox>
</Window>

Http://msdn.microsoft.com/en-us/library/system.windows.controls.viewbox.aspx
Edited Myyvictor May 21, 2014 3:27 has been marked as an answer Jimmy-yangMicrosoft contingent staff, moderator May 22, 2014 9:02 May 21, 2014 3:20 reply | Reference

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.