WPF DataGrid全行多选样式 [英] WPF DataGrid full row multi selection style

查看:247
本文介绍了WPF DataGrid全行多选样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在偶然发现了这个荒谬的问题几天,并且会感激任何人对此事的任何智慧。

我正在努力实现一个DataGrid多行选择将设置最后选择的行(如果可能的话,聚焦行,看起来DataGrid对象不支持)与其他所选行具有不同的背景并在其周围绘制边框。

我需要一个虚拟化控件,所以就我所知,ListView不是一个可行的解决方案。

如何在WPF中实现它?我管理到目前为止只禁用单元格选择矩形...

提前谢谢!



编辑:为了进一步澄清我的意思'我试图发布我最近失败的尝试...:



I''m stumbled on this ridiculous problem for a few days now, and would appreciate any bits of wisdom any one has on the matter.
I''m trying to implement a DataGrid with multiple row selection that will set the last selected row (focused row if i may, tho it appears to not be supported by the DataGrid object) to have a different background from the other selected rows and draw a border around it.
I need a virtualizing control, so a ListView is not a viable solution as far as i know.
How would one go about it in WPF? I managed so far only disable the cell selection rectangle...
Thanks in advance!

In order to further clarify what i''m trying to do i post my latest failed attemp..:

<DataGrid.RowStyle>
    <Style TargetType="{x:Type DataGridRow}">
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSelected" Value="True"/>
                    <Condition Property="IsFocused" Value="True"/>
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="#FF3399FF"/>                            
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="BorderBrush" Value="Black"/>                            
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSelected" Value="True"/>
                    <Condition Property="IsFocused" Value="False"/>
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="#993399FF"/>
            </MultiTrigger>
        </Style.Triggers>
    </Style>
</DataGrid.RowStyle>





如果只有一行会以某种方式获得焦点,这将会很好用。

我想知道为什么IsFocused属性即使在那里DataGridRow没有得到焦点?



This would work nice if only the row will somehow get focus....
I do wonder why is the IsFocused property even there if DataGridRow don''t receive focus?

推荐答案

认为你需要自定义颜色和边框选择然后:

http://social.msdn。 microsoft.com/Forums/en-US/ wpf / thread / a5fd5413-f055-4b56-83af-6d6bdb1d6fe9 / [ ^ ]
Think youll need custom color and border selection then:
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/a5fd5413-f055-4b56-83af-6d6bdb1d6fe9/[^]


请查看此链接

http://www.c-sharpcorner.com/uploadfile/nipuntomar/wpf-datagrid-style/ [ ^ ]

你需要根据你的要求修改一些样式
Please check this link
http://www.c-sharpcorner.com/uploadfile/nipuntomar/wpf-datagrid-style/[^]
you need to modify some styles as per your requriement


这篇关于WPF DataGrid全行多选样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆