如何使用数据触发器的默认样式?

How to use default style with datatriggers?

我从 MaterialDesignInXaml 中设置了默认样式,当我尝试向控件添加数据触发器时,它并没有使用相同的样式。

如何在有数据触发器的情况下仍然使用默认样式?

<TextBox Margin="10" VerticalAlignment="Bottom" Padding="5" materialDesign:HintAssist.Hint="Search">
       <TextBox.Style>
              <Style BasedOn="{StaticResource MaterialDesignOutlinedTextBox}"> <!--Not Allowed to do this -->
                  <Setter Property="TextBox.Visibility" Value="Collapsed"></Setter>
                  <Style.Triggers>
                       <DataTrigger Binding="{Binding ElementName=SearchStyle, Path=SelectedItem.Tag}" Value="Search">
                            <Setter Property="Label.Visibility" Value="Visible"></Setter>
                       </DataTrigger>
                  </Style.Triggers>
              </Style>                       
        </TextBox.Style>
</TextBox>

您必须为与基本样式匹配的 Style 指定确切的 TargetType

[...] if you create a style with a TargetType property and base it on another style that also defines a TargetType property, the target type of the derived style must be the same as or be derived from the target type of the base style.

<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignOutlinedTextBox}">

source code 中,MaterialDesignOutlinedTextBox 样式具有 TextBox 目标类型。