为什么一个窗口在运行较大? [英] Why is a window larger in runtime?

查看:146
本文介绍了为什么一个窗口在运行较大?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个窗口设置为340 x 146像素,不可调整大小。



在设计器窗口大小是正确的。但是当我运行该应用程序就越大。



编辑:另外,布局画布



经典主题:





EDIT2



运行窥探(感谢扎克)后,似乎实际尺寸是我指定的。
,而客户区是大于1的Visual Studio。



我现在明白了,客户端大小绵延,当窗口大小固定为一定规模。但我认为这使得Canvas布局窗口不可用



EDIT3:

 <窗口x:类=TI.Presentation.Views.AutentizationWindow
的xmlns =http://schemas.microsoft.com/winfx/2006/xaml/presentation
的xmlns:X =http://schemas.microsoft.com/winfx/2006/xaml
标题=验证HEIGHT =146WIDTH =340ResizeMode =NoResize背景={StaticResource的{X:静态SystemColors.ControlBrushKey}}>
<&帆布GT;
<标签Canvas.Left =12Canvas.Top =12字号=15WIDTH =217>此处输入验证码:< /标签>
<文本框Canvas.Left =12Canvas.Top =38HEIGHT =23NAME =代码WIDTH =294字号=14/>
<按钮Canvas.Top =67CONTENT =OKHEIGHT =28WIDTH =100Canvas.Left =206字号=14ISDEFAULT =真点击=OKClick />
< /帆布>
< /窗GT;


解决方案

我要去打探后,这个答案我自己



该窗口的ActualWith和的ActualHeight等于宽度和高度在设计设置。



什么改变,是客户端领域。客户端的尺寸将是窗口尺寸减去主题边界。然而,这打破了帆布设计,因为它的绝对定位和画布的尺寸发生变化,按主题。



,使画布设计工作的方式。是设置在画布的尺寸,在窗口中删除的尺寸和窗口设置相应SizeToContent。通过这种方式,cavnas尺寸保持固定,并根据窗口大小的变化是怎么想的主题边境。


I have a window set to 340 x 146 px, not resizable.

In designer the window size is correct. But when I run the application it is bigger.

Edit: Also, the layout is Canvas.

Classic theme:

Edit2:

After running snoop (thanks Zach), it appears that actual dimensions are what I specified. But the client area is bigger than one in visual studio.

I understand now that the client size stretches, when windows size is fixed to certain dimensions. However I think this makes Canvas layout in window unusable.

Edit3:

<Window x:Class="TI.Presentation.Views.AutentizationWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Authentication" Height="146" Width="340" ResizeMode="NoResize" Background="{StaticResource {x:Static SystemColors.ControlBrushKey}}" >
    <Canvas>
        <Label Canvas.Left="12" Canvas.Top="12" FontSize="15" Width="217">Enter authentication code here:</Label>
        <TextBox Canvas.Left="12" Canvas.Top="38" Height="23" Name="code" Width="294" FontSize="14" />
        <Button Canvas.Top="67" Content="OK" Height="28" Width="100" Canvas.Left="206" FontSize="14" IsDefault="True" Click="OKClick" />
    </Canvas>
</Window>

解决方案

I'm going to answer this myself after poking around.

The window's ActualWith and ActualHeight are equal to Width and Height set in the designer.

What changes, is the client area. The dimensions of client are will be window dimensions minus theme border. This, however, breaks Canvas design because its absolutely positioned and canvas dimensions changed based on theme.

The way to make Canvas design work. Is to set dimensions on Canvas, remove dimensions on window and set SizeToContent on window accordingly. This way, cavnas dimensions stay fixed and Window size changes based on how think the theme border is.

这篇关于为什么一个窗口在运行较大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆