1
다음
내 코드입니다 :GridSplitter를 사용하여 컨트롤의 크기를 올바르게 조정하는 방법?
<Window
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"
mc:Ignorable="d"
Title="MainWindow" Height="673" Width="1008" >
<Grid Margin="0, 0, 8, 8">
<Grid.Resources>
<Style TargetType="{x:Type Control}">
<Setter Property="Margin" Value="8, 8, 0, 0" />
</Style>
<Style TargetType="{x:Type Label}" BasedOn="{StaticResource {x:Type Control}}" />
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Control}}" />
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type Control}}" />
<Style TargetType="{x:Type CheckBox}" BasedOn="{StaticResource {x:Type Control}}" />
<Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource {x:Type Control}}" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="7"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBox x:Name="original_text" TextWrapping="Wrap" AcceptsReturn="True" Text="text1" />
<GridSplitter Grid.Row="1" Background="AntiqueWhite" HorizontalAlignment="Stretch" />
<Grid x:Name="grid2" Grid.Row="2" Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<CheckBox IsChecked="True" Content="aaaa" VerticalAlignment="Center" />
<CheckBox IsChecked="True" Content="bbbb" Grid.Row="1" VerticalAlignment="Center" />
<CheckBox IsChecked="True" Content="cccc" VerticalAlignment="Center" Grid.Column="1" />
<CheckBox IsChecked="False" Content="dddd" VerticalAlignment="Center" Grid.Column="1" Grid.Row="1" />
<Label Content="aaa" Grid.Column="2" VerticalAlignment="Center" Margin="20, 0, 0, 0" />
<ComboBox Grid.Column="2" Grid.Row="1" VerticalAlignment="Center" Margin="24, 0, 0, 0">
<ComboBoxItem IsSelected="True">eeee</ComboBoxItem>
</ComboBox>
<Label Content="asdf" Grid.Column="3" VerticalAlignment="Center" Margin="20, 0, 0, 0" />
<ComboBox Grid.Column="3" Grid.Row="1" VerticalAlignment="Center" Margin="24, 0, 0, 0" IsEditable="True" Width="130">
<ComboBoxItem IsSelected="True">fff</ComboBoxItem>
<ComboBoxItem>ggg</ComboBoxItem>
</ComboBox>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="0" Grid.RowSpan="2" Grid.Column="4">
</StackPanel>
</Grid>
<TextBox TextWrapping="Wrap" AcceptsReturn="True" Grid.Row="3" FontFamily="Courier New" Text="text2" />
</Grid>
</Window>
그리고는 다음과 같습니다
내가 구현하고자하는 동작은 사용자가 GridSplitter를 드래그 할 때, 그 텍스트 1의 크기를 바꿀 수 있다는 점이며, text2. 가운데 부분 grid2는 원래 크기를 유지해야합니다. 이것이 가능한가? 누군가가 나를 올바른 방향으로 가리킬 수 있기를 바랍니다. 미리 감사드립니다.
당신을 감사합니다! 그것은 작동하고 당신은 내게 올바른 방향을 지적했습니다. – user130268