简体   繁体   English

Visual Studio 2010 WPF Designer规模

[英]Visual Studio 2010 WPF Designer scale

I made simple interface in Visual Studio 2010. When I launched application everything is bigger. 我在Visual Studio 2010中创建了简单的界面。当我启动应用程序时,一切都变得更大。 Red square on screenshot represents size of the Button in launched application (On the right). 屏幕截图上的红色方块表示已启动应用程序中按钮的大小(右侧)。 Am I missing something? 我错过了什么吗? How to fix it? 怎么解决?

PS In "Microsoft Expression Blend 4" the same project is exactly the same size as in editor. PS在“Microsoft Expression Blend 4”中,同一项目的大小与编辑器中的大小完全相同。


视窗缩放滑块


<Window x:Class="WpfControlReview.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Height="120" Width="256" ResizeMode="NoResize">
    <Grid>
        <Button HorizontalAlignment="Stretch" Name="button1" VerticalAlignment="Stretch">
        <StackPanel HorizontalAlignment="Stretch" Name="stackPanel1" VerticalAlignment="Center">
            <Label IsHitTestVisible="False" Content="Select your options and press to commit" Name="label1" HorizontalContentAlignment="Center" FontSize="12" />
            <StackPanel Name="stackPanel2" Orientation="Horizontal">
                <Expander Header="Color" Name="expander1">
                </Expander>
                <Expander Header="Make" Name="expander2">
                </Expander>
                <Expander Header="Payment" Name="expander3">
                </Expander>
            </StackPanel>
        </StackPanel>
        </Button>
    </Grid>
</Window>

Are you zoomed out in the visual studio designer? 你是否在视觉工作室设计师中缩小了? Check the trackbar to your left and scroll it up and down to zoom in and out. 检查左侧的轨迹栏并上下滚动以放大和缩小。

I'm not sure if this is a bug or not, but the basic idea here is that you have specifed a default size for your window, but because the control wants to be bigger (for whatever reason) it will automatically resize the window. 我不确定这是不是一个bug,但这里的基本思想是你已经为你的窗口指定了默认大小,但由于控件想要更大(无论出于何种原因),它会自动调整窗口大小。 Could be a bug how Visual Studio calculates window border size in the designer with the specified parameters as it's incorrectly showing it as a bit smaller than when you actually launch your application. 可能是Visual Studio在设计器中使用指定参数计算窗口边框大小的错误,因为它错误地将其显示为比实际启动应用程序时小一点。

I would rather suggest that you avoid specifying heights/widths if possible. 我宁愿建议您尽可能避免指定高度/宽度。 Instead set the Window to SizeToContent=WidthAndHeight. 而是将Window设置为SizeToContent = WidthAndHeight。 If you need to play with the size of your controls use Margins or MinWidth/MinHeight set directly on your controls. 如果您需要使用控件的大小,请直接在控件上设置边距或MinWidth / MinHeight。

Remeber that WPF scales the UI. 记住WPF扩展UI。 Have you played with your DPI settings at all? 你玩过DPI设置了吗? This will affect the render of the UI componets on the display. 这将影响显示器上UI组件的渲染。 Try running the app on a secondary machine to eleimate display issues. 尝试在辅助计算机上运行应用程序以解决显示问题。

From MSDN: 来自MSDN:

Resolution-independent and device-independent graphics. 与分辨率无关且与设备无关的图形。 The basic unit of measurement in the WPF graphics system is the device independent pixel, which is 1/96th of an inch, regardless of actual screen resolution, and provides the foundation for resolution-independent and device-independent rendering. WPF图形系统中的基本测量单位是与设备无关的像素,无论实际的屏幕分辨率如何,都是1/96英寸,为独立于分辨率和与设备无关的渲染提供了基础。 Each device-independent pixel automatically scales to match the dots-per-inch (dpi) setting of the system it renders on. 每个与设备无关的像素会自动缩放以匹配其渲染的系统的每英寸点数(dpi)设置。

http://msdn.microsoft.com/en-us/library/aa970268.aspx http://msdn.microsoft.com/en-us/library/aa970268.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM