I’m trying to make two different search TextBoxes surface depending on which TabItem is selected in a TabControl. The xaml for the search text boxes is as follows:
<Grid HorizontalAlignment="Right">
<Grid Panel.ZIndex="1">
<Grid.Style>
<Style TargetType="Grid">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=methodItem, Path=IsSelected}" Value="True">
<Setter Property="Panel.ZIndex" Value="1" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=methodItem, Path=IsSelected}" Value="False">
<Setter Property="Panel.ZIndex" Value="-1" />
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<xctk:WatermarkTextBox Watermark="Search methods"
"Text="{Binding MethodFilter, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
<Grid x:Name="compoundOverlay" Panel.ZIndex="0">
<xctk:WatermarkTextBox Watermark="Search compounds"
Text="{Binding CompoundFilter, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</Grid>
I’m attemting to use the ZIndex property to switch between the two search boxes bound to different filters. Here’s the simplified TabControl:
<TabControl>
<TabItem x:Name="methodItem" Header="Methods"/>
<TabItem x:Name="compoundItem" Header="Compounds"/>
</TabControl>
Any idea what I’m doing wrong? Is there a better approach?