0

我有这种风格:

private Style ColorStyle(Container.ColorTrigger trigger)
        {
            Style style = new Style();
            style.TargetType = typeof(DataGridRow);           
            DataTrigger dtGreen = new DataTrigger();
            bool triggervalue = Convert.ToBoolean(trigger.Trigger);

            IValueConverter converter = AssignConverter(trigger.Operator);         
            dtGreen.Binding = new Binding(trigger.Binding) { Converter = converter, ConverterParameter = trigger.Value };
            dtGreen.Value = !triggervalue;
            dtGreen.Setters.Add(new Setter(Control.BackgroundProperty, Brushes.LawnGreen));
            DataTrigger dtRed = new DataTrigger();
            dtRed.Binding = new Binding(trigger.Binding) { Converter = converter, ConverterParameter = trigger.Value };
            dtRed.Value = triggervalue;
            dtRed.Setters.Add(new Setter(Control.BackgroundProperty, Brushes.Red));
            style.Triggers.Add(dtGreen);
            style.Triggers.Add(dtRed);

            return style;
        }

样式设置在DataGrid.

当触发器设置为时,如何调用方法Brushes.Red以及BackgroundProperty如何获取更改背景的行。

4

1 回答 1

0

在 Binding 中的 TargetUpdated 上附加一个处理程序。

http://msdn.microsoft.com/en-us/library/system.windows.data.binding.targetupdated.aspx

于 2013-10-15T09:44:34.600 回答