我有一个标签控件,我在其中修改了模板。目标是将一个Toggle按钮放在TabItems组的右侧和TabContent上方。这有效。单击切换按钮时,我需要调出显示在我的切换按钮下面但位于TabContent上的面板。
我以为我可以用ZIndex实现这个目标,但到目前为止我还没有成功。 “窗口”位于TabContent后面或推出Tab区域。
<Style TargetType="{x:Type TabControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Height="20">
<TabPanel Grid.Row="0" Panel.ZIndex="1" Margin="0,0,4,-1" IsItemsHost="True" Background="Transparent" />
<UniformGrid Columns="3" Rows="1" Height="20" Width="500" Margin="150,0,0,0">
<WrapPanel Height="20">
<Label Content="Status" Margin="0,0,5,0" Padding="0,0,0,0" VerticalContentAlignment="Center" Height="Auto" />
<ToggleButton Height="18" Padding="0,0,0,0">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Unchecked">
<ei:ChangePropertyAction TargetName="StatusOverlay" PropertyName="Visibility" Value="Collapsed" />
</i:EventTrigger>
<i:EventTrigger EventName="Checked">
<ei:ChangePropertyAction TargetName="StatusOverlay" PropertyName="Visibility" Value="Visible"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<WrapPanel Margin="0,0,0,0">
<Path Style="{StaticResource StatusSuccess}" />
<Path Style="{StaticResource StatusFailure}" />
<Path Style="{StaticResource StatusSuccess}" />
</WrapPanel>
</ToggleButton>
</WrapPanel>
<!-- Placeholder for another item-->
<WrapPanel Height="20">
</WrapPanel>
<!-- Placeholder for another item-->
<WrapPanel Height="20">
</WrapPanel>
</UniformGrid>
</StackPanel>
<!-- This would be the Panel I want to sit on top -->
<Border x:Name="StatusOverlay" Panel.ZIndex="99" BorderBrush="Black" BorderThickness="3" HorizontalAlignment="Left" Height="403" VerticalAlignment="Top" Width="325" Background="#FFD9D9D9" CornerRadius="6" Visibility="Collapsed">
</Border>
<Border Panel.ZIndex="1" Grid.Row="1" BorderBrush="Black" BorderThickness="1" CornerRadius="0, 12, 12, 12" >
<Border.Background>
<LinearGradientBrush>
<GradientStop Color="LightBlue" Offset="0" />
<GradientStop Color="White" Offset=".5" />
</LinearGradientBrush>
</Border.Background>
<ContentPresenter ContentSource="SelectedContent" />
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>