Wpf 将datatrigger样式绑定到内容绑定对象的属性
我试着做以下几点。我有一个绑定到具有两个属性的对象的标签。一个我想显示,一个我想用于datatrigger 这是我想到的:Wpf 将datatrigger样式绑定到内容绑定对象的属性,wpf,xaml,binding,styles,datatrigger,Wpf,Xaml,Binding,Styles,Datatrigger,我试着做以下几点。我有一个绑定到具有两个属性的对象的标签。一个我想显示,一个我想用于datatrigger 这是我想到的: <Label Grid.Row="5" Content="{Binding ElementName=InformationUserControl, Path=Info.ObjectBound}"> <Label.Style> <Style TargetType="{x:Type Label}">
<Label Grid.Row="5" Content="{Binding ElementName=InformationUserControl, Path=Info.ObjectBound}">
<Label.Style>
<Style TargetType="{x:Type Label}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource self}, Path=Content.InterpretationValue}">
<DataTrigger.Value>
<enums:DataInterpretation>Neutral</enums:DataInterpretation>
</DataTrigger.Value>
<Setter Property="Background" Value="Red" />
</DataTrigger>
</Style.Triggers>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Label}">
<TextBlock Text="{TemplateBinding Content.Value}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Label.Style>
</Label>
中立的
问题是我的模板会覆盖默认模板,因此它不会显示任何内容。有没有办法让它发挥作用
谢谢 我认为问题不在于覆盖模板,而在于绑定被破坏,我会尝试以下方法:
<TextBlock Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Content.Value}" />