1 回答
TA贡献1779条经验 获得超6个赞
由于您正在折叠正确的项目,因此控件不会出现在面板中。而不是制作 Visibility Collapsed。单击按钮时,我们可以将宽度设置为 10,再次单击时,我们可以将其恢复为原始宽度。同时,我们也可以拖动GridSplitter.
private void deatilsShowHide(object sender, RoutedEventArgs e)
{
if(rightColumn.Width == new GridLength(10))
{
rightColumn.Width = new GridLength(300);
}
else
{
rightColumn.Width = new GridLength(10);
}
}
Xaml:-
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="300" x:Name="rightColumn"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Column="0" Background="AliceBlue">
<Button Width="50" Height="50" HorizontalAlignment="Right" x:Name="Details_Toggle" Focusable="False" Click="Details_Toggle_Click">
<StackPanel>
</StackPanel>
</Button>
</StackPanel>
<GridSplitter x:Name="rightSplitter"
Width="15" Grid.Column="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="Transparent"
ShowsPreview="True" />
<StackPanel Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" >
<Button Content="test" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75"/>
</StackPanel>
</Grid>
- 1 回答
- 0 关注
- 343 浏览
添加回答
举报