DataTrigger没有设置不透明度

时间:2018-11-20 04:44:13

标签: c# wpf

我有一个带有数据触发器的数据网格。

            <Style TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource {x:Type DataGridRow}}">
                <Setter Property="ContextMenu" Value="{StaticResource RowMenu}" />
                <Setter Property="IsSelected" Value="{Binding IsSelected}" />
                <Setter Property="Opacity" Value="1"/>
                <Style.Triggers>
                    <DataTrigger x:Uid="DataTrigger_1" x:Name="RowMenuDataTrigger" Binding="{Binding IsModified, diag:PresentationTraceSources.TraceLevel=High}" Value="True">
                        <Setter x:Uid="Setter_1" Property="Opacity" Value="0.5" />
                        <Setter x:Uid="Setter_2" Property="ToolTip">
                            <Setter.Value>
                                <MultiBinding x:Uid="MultiBinding_1" Converter="{StaticResource ModifiedTypeMessage}">
                                    <Binding x:Uid="Binding_1" Path="Class"></Binding>
                                    <Binding x:Uid="Binding_2" Path="OriginalClassName" ></Binding>
                                </MultiBinding>
                            </Setter.Value>
                        </Setter>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

        </control:DataGrid.RowStyle>

和IMultiValueConverter看起来像:

public class EnTypeModifiedMessageConverter : IMultiValueConverter
{
    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
    {
        if (values.Length == 2)
        {
            string current = values[0].ToString();
            string original = values[1].ToString();

            if (current != original)
            {
                return string.Format(LanguageHelper.LocalizedString("RawTypeModified"), original.ToUpper());
            }
        }
        return string.Empty;
    }

    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
    {
        return null;
    }
}

当数据更改时,我得到控制击中该转换器。但用户界面仍未更新。即不透明度和工具提示保持不变。

0 个答案:

没有答案