0

次の XAML コードを使用して単純な WPF アプリケーションを作成しました。

<Window x:Class="WpfApplication1.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" SizeToContent="WidthAndHeight">
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <Button MinWidth="200" MinHeight="40" Content="Hello 1"/>
    <Button MinWidth="200" MinHeight="40" Content="Hello 2" Grid.Column="1"/>

</Grid>
</Window>

アプリケーションを起動すると、ウィンドウのサイズを 2 つのボタンよりも小さいサイズに変更できます。

ご覧のとおり、MinWidth プロパティと MinHeight プロパティを使用しましたが、機能しませんでした。

この場合、私を助けてください。

よろしく、

トーマス

4

2 に答える 2

-1

MinHeight と MinWidth を WINDOW レベルに追加して、コンテンツ内で予想される最小の要素よりも小さくならないようにすることもできます...

Title="MainWindow" Height="350" Width="525" MinHeight="90" MinWidth="410" SizeToContent="WidthAndHeight"

2 つのボタンの高さ 40 (80) プラス任意のギャップ (10) = 最小高さ 90... 幅についても同様です。200 の 2 つのボタンの最小幅 = 合計 400 プラス任意のギャップ (10) = 410。

于 2012-10-17T16:52:23.527 に答える