当触发器设置属性时调用方法

时间:2013-10-15 07:56:08

标签: wpf datagrid

我有这种风格:

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时,如何调用方法?如何获取背景更改的行。

1 个答案:

答案 0 :(得分:0)