直接将数据绑定到setter值

时间:2014-10-20 14:59:13

标签: c# .net wpf data-binding setter

如何将我的ViewModel中的画笔绑定到setter值?

<DataGrid.CellStyle>
    <Style TargetType="{x:Type DataGridCell}">
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="{Binding SelectionBrush, Mode=OneWay}" />
                <Setter Property="BorderBrush" Value="{Binding SelectionBrush, Mode=OneWay}" />
            </Trigger>
        </Style.Triggers>
    </Style>
</DataGrid.CellStyle>

class Leerformular
{
    public Leerformular()
    {
        SelectionBrush = (SolidColorBrush)(new BrushConverter()).ConvertFromString(settings.SelectionBrush);
    }

    public SolidColorBrush SelectionBrush
    {
        get { return selectionBrush; }
        set
        {
            if (selectionBrush != value && value != null)
            {
                selectionBrush = value;
                OnPropertyChanged("SelectionBrush");
            }
        }
    }
}

当我执行程序时,当我选择单元格时,没有任何事情发生。

0 个答案:

没有答案