[在我的DataGridTextColumn
上,我只想运行DataTrigger
,但仅当Validation.HasError
为False
时
这是我目前所拥有的:
<DataGridTextColumn Header="Volts"
Binding="{Binding DcVolts, Converter={StaticResource StringToDecimalConverter}}"
Width="Auto">
<DataGridTextColumn.ElementStyle>
<Style TargetType="{x:Type TextBlock}"
BasedOn="{StaticResource DataGridTextColumnElementErrorStyle}">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=Validation.HasError}"
Value="False" />
<Condition Value="False">
<Condition.Binding>
<MultiBinding Converter="{StaticResource EqualityConverter}">
<Binding Path="DcVolts" />
<Binding Path="DcSpecVolts" />
</MultiBinding>
</Condition.Binding>
</Condition>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="Background" Value="Orange" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</DataGridTextColumn.ElementStyle>
后面的想法是,如果Validation.HasError
的结果为False
,则MultiDataTrigger
必须为BackGround
才能将Orange
设置为EqualityConverter
这是因为如果False
为Validation.HasError
,那么当我在True
上设置的规则失败时,我希望Pink
提供的通常的DataGridTextColumnElementErrorStyle
背景。
我实际上与之接近:
Property
但是问题是<DataGridTextColumn Header="Volts"
Binding="{Binding DcVolts, Converter={StaticResource StringToDecimalConverter}}"
Width="Auto">
<DataGridTextColumn.ElementStyle>
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource DataGridTextColumnElementErrorStyle}">
<Style.Triggers>
<DataTrigger Value="False">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource EqualityConverter}" >
<Binding Path="DcVolts" />
<Binding Path="DcSpecVolts" />
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="Background" Value="Orange" />
</DataTrigger>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="Background" Value="Pink" />
</Trigger>
</Style.Triggers>
</Style>
</DataGridTextColumn.ElementStyle>
上复制的Validation.HasError
中提供的消息(根据我创建的规则)。>
非常感谢任何建议。
在我的DataGridTextColumn上,我只想在Validation.HasError为False时运行一个DataTrigger,这是我目前所拥有的:
由于ToolTip
是附加属性,因此应在绑定路径周围添加括号: