【问题标题】:Change DatagridCell Foreground while editing编辑时更改 DatagridCell 前景
【发布时间】:2014-08-07 11:08:03
【问题描述】:

如何在编辑数据网格的单元格时更改前景色? 颜色只能在编辑时更改。

【问题讨论】:

    标签: wpf wpfdatagrid wpftoolkit


    【解决方案1】:

    在列上使用 EditingElementStyle。像这样:

        <DataGrid ItemsSource="{Binding Items}" CanUserAddRows="True">
            <DataGrid.Columns>
                <DataGridTextColumn Header="col1" Binding="{Binding myString}">
                    <DataGridTextColumn.EditingElementStyle>
                        <Style TargetType="TextBox">
                            <Setter Property="Foreground" Value="Blue" />
                            <Setter Property="Background" Value="Yellow" />
                        </Style>
                    </DataGridTextColumn.EditingElementStyle>
                </DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>
    

    【讨论】:

      猜你喜欢
      • 2015-04-05
      • 1970-01-01
      • 2011-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多