突出显示单元格边框/背景颜色WPF,MVVM XamDataGrid [英] Highlighting a cell border/background color WPF, MVVM XamDataGrid

查看:202
本文介绍了突出显示单元格边框/背景颜色WPF,MVVM XamDataGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

i我在WPF应用程序中使用MVVM架构,现在它的工作正常,因为当我在Costcenter单元格中进行一些更改onlostfocus时,bordercolor或背景颜色会发生变化,就像明智一样当数据在gris中填充时,颜色应该被更改,而它的绑定本身应该突出显示。我怎么能这样做呢?我的工作代码在下面。我对此非常感兴趣。





< Style x:Key =costCenterStyleTargetType ={x:Type igDataPresenter:CellValuePresenter}BasedOn ={StaticResource isEditableStyle}>

< Style.Triggers>

< DataTrigger Binding ={绑定路径= DataItem.IsChanged [CostCenter]}Value =已更改>

< Setter Property =BackgroundValue =LightSalmon/>

< / DataTrigger>

< DataTrigger Binding ={Binding Path = DataItem.IsChanged [CostCenter]}Value =ChangedButNotCommited>

< Setter Property =BorderThickness值=2/>

< Setter Property =BorderBrushValue =LightSalmon/>

< / DataTrigger>

< /Style.Triggers>

< / Style>





< igDataPresenter:Field Name =CostCenterLabel =Cost Center>

< igDataPresenter:Field.Settings>

< igDataPresenter:FieldSettings

CellValuePresenterStyle ={StaticResource costCenterStyle}/>

< / igDataPresenter:Field.Settings>

< / igDataPresenter:Field>



谢谢

Kannabiran B

解决方案

你想根据某些条件设置单元格的颜色吗?如果是这样,请检查这些使用转换器

http://stackoverflow.com/questions/6986898/change-color-of-datagrid-cell-wpf-regarding-range [ ^ ]





这里检查Padma的解决方案......

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/8f725b42-2e5e-45ef-9629-cccbcdba559f/ [ ^ ]

Hi all,
i am using MVVM architecture in WPF application, right now its working fine as when i made some changes in the Costcenter cell onlostfocus the bordercolor or background color will get change, like wise the color should get changed while its binding itself when the data is populated in the gris itshould be highlighted. How can i do that any idea? My working code is below.since im very new to this getting struck.


<Style x:Key="costCenterStyle" TargetType="{x:Type igDataPresenter:CellValuePresenter}" BasedOn="{StaticResource isEditableStyle}" >
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DataItem.IsChanged[CostCenter]}" Value="Changed">
<Setter Property="Background" Value="LightSalmon"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=DataItem.IsChanged[CostCenter]}" Value="ChangedButNotCommited">
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="BorderBrush" Value="LightSalmon"/>
</DataTrigger>
</Style.Triggers>
</Style>


<igDataPresenter:Field Name="CostCenter" Label="Cost Center">
<igDataPresenter:Field.Settings>
<igDataPresenter:FieldSettings
CellValuePresenterStyle="{StaticResource costCenterStyle}"/>
</igDataPresenter:Field.Settings>
</igDataPresenter:Field>

Thanks
Kannabiran B

解决方案

Do you want to set the color for the cell while binding itself based on some condition??? if so, please check these which uses converters
http://stackoverflow.com/questions/6986898/change-color-of-datagrid-cell-wpf-regarding-range[^]


Here check for Padma''s solution...
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/8f725b42-2e5e-45ef-9629-cccbcdba559f/[^]


这篇关于突出显示单元格边框/背景颜色WPF,MVVM XamDataGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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