【发布时间】:2013-02-06 08:37:16
【问题描述】:
我有这个标记的窗口
<Window x:Class="TestCloseWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow">
<Button Command="ApplicationCommands.Close">Foo</Button>
</Window>
我想按钮 MinWidth 和 MinHeight 100 并且 MaxHeight 和 MinHeight 等于 500
并且喜欢将窗口大小设置为内容,所以我制作了这个
<Window x:Class="TestCloseWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" SizeToContent="WidthAndHeight" >
<Button MaxHeight="500" MaxWidth="500" MinHeight="100" MinWidth="100" Command="ApplicationCommands.Close">Foo</Button>
</Window>
我想将按钮的初始大小设置为 200 x 200 不在窗口中写宽度和高度
如果我在按钮中写 Width="200" Height="200",按钮变得不可调整大小。
如何设置初始控件的大小?
【问题讨论】:
-
所以你想让元素知道你想要它的大小而不告诉它?
-
@sa_ddam213 我想以某种方式告诉元素的初始大小。如果我把 Width="200" Height="200" 元素变得无法调整大小
标签: wpf