【发布时间】:2021-01-17 12:20:02
【问题描述】:
我正在开发侧边栏 wpf 应用程序。侧边栏有几个停靠面板。我的问题是,如何根据单击按钮在侧边栏中折叠/可见相同的停靠面板。例如:按钮 1 应该是折叠 dockPanel1 和里面的所有东西。按钮 2 应该显示它。
这是一个例子:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="370*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Background="Black" x:Name="sidebarControl">
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<DockPanel LastChildFill="False">
<Image DockPanel.Dock="Top" Source="{StaticResource logo}" />
<DockPanel DockPanel.Dock="Top" Height="160" Name="dockPanel1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="80"></RowDefinition>
<RowDefinition Height="80"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<Label Content="Label1"></Label>
<Label Content="Label2"></Label>
</StackPanel>
<StackPanel Grid.Row="1">
<Label Content="Label3"></Label>
<Label Content="Label4"></Label>
</StackPanel>
</Grid>
</DockPanel>
<DockPanel DockPanel.Dock="Top" Height="160" Name="dockPanel2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="80"></RowDefinition>
<RowDefinition Height="80"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<!-- other content -->
</StackPanel>
<StackPanel Grid.Row="1">
<!-- other content -->
</StackPanel>
</Grid>
</DockPanel>
</DockPanel>
</Grid>
</Grid>
【问题讨论】:
标签: wpf xaml data-binding