How to style a WPF DataGridCell dynamically

允我心安 提交于 2019-12-06 06:00:01

Any chance of seeing your slow Xaml? I would have thought that doing this with a datatrigger wouldn't be too awful (also which version of the data grid are you using as the .net 4.0 and the WPF Toolkit versions are different)

I've done stuff like this to recolor for selected items and it didn't seem too slow (this isn't the right solution but I'd like a little more detail before I say any more):

        <Style TargetType="DataGrid">
        <Setter Property="CellStyle">
            <Setter.Value>
                <Style TargetType="DataGridCell">
                    <Style.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Background" Value="{StaticResource SelectedBackgroundBrush}" />
                            <Setter Property="BorderBrush" Value="{x:Null}" />
                            <Setter Property="Foreground" Value="White" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Setter.Value>
        </Setter>
    </Style>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!