WPF切换面板可见性

Kar*_*ten 6 c# wpf xaml visibility panel

我有两个面板,只有一个应该同时可见.我通过单击每个面板上的一个按钮在它们之间进行切换.

有没有一种很好的方法在没有codebehind或viewmodel的xaml中执行此操作?

Kar*_*ten 2

使用选项卡控件的建议很好。我发现一些代码将 TabControl 的样式设置为仅显示 TabItem 内容

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid>
    <TabControl BorderThickness="0" Padding="0">
      <TabControl.Resources>
        <Style TargetType="TabItem">
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="TabItem">
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style>
      </TabControl.Resources>
      <TabItem Header="Not shown">
        <Grid Background="Red"/>
      </TabItem>
      <TabItem>
        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Tab 2

        </TextBlock>
      </TabItem>
    </TabControl>
  </Grid>
</P
Run Code Online (Sandbox Code Playgroud)