0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Visual Studio / WPF > コントロール > レイアウト > MinHeight / MaxHeight

Last updated at Posted at 2017-04-24
動作環境
Windows 7 Pro (32bit)
Microsoft Visual Studio 2017 Community
Sublime Text 2

@ WPF 4.5入門 by 大田一希さん
No.2727 / 9985

コントロール自身の大きさを指定するプロパティとして以下を紹介している。

  • Width
  • Height
  • MinWidth
  • MinHeight
  • MaxWidth
  • MinHeight
    • Note: MaxHeightの間違いのようだ

MinHeightとMaxHeightを使ってみた。

XAML
<Window x:Class="_170425_t0650_gridSplitter.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:_170425_t0650_gridSplitter"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Grid ShowGridLines="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="150"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Button Grid.Row="0" Grid.ColumnSpan="2" Content="Menu"/>
        <Button Grid.Row="1" Grid.ColumnSpan="2" Content="Toolbar"/>
        <Button Grid.Row="3" Grid.ColumnSpan="2" Content="Status Bar"/>
        <Button Grid.Row="2" MinHeight ="50" MaxHeight="100"
                Content="Tree" Margin="0,5,0,0"/>
        <GridSplitter Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Stretch"
                      VerticalAlignment="Top" Height="5"/>
        <Button Grid.Row="2" Grid.Column="1" Content="Content" Margin="0,5,0,0"/>
    </Grid>
</Window>

TreeボタンにMaxHeight適用時。
db6f69f6-5a86-1491-6eee-bfc2df50b2d6.png

TreeボタンにMinHeight適用時。
c39438f6-e255-71b2-1047-022a47a0aa13.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?