DevExpress控件使用交流,DevExpress中国社区Dev联系电话 联系电话:023-68661681

如何自定义DevExpress.DXGrid for WPF单元格样式?

来源:本站原创   发布时间:2012-08-08   浏览:3450次

本示例主要演示了如何自定义单元格样式(如果产品单位数量少于20,产品名称就突出显示)。

<Window x:Class="DXGrid_ConditionalFormatting.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DXGrid_ConditionalFormatting"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxgt="http://schemas.devexpress.com/winfx/2008/xaml/grid/themekeys"
Title="Window1" Height="300" Width="470">
<Grid>
<dxg:GridControl x:Name="grid">
<dxg:GridControl.Resources>
<Style x:Key="customCellStyle"
BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=CellStyle}}"
TargetType="dxg:CellContentPresenter">
<Setter Property="Background"
Value="{Binding Path=RowData.Row.UnitsOnOrder, Converter={local:IntoToColorConverter}}"/>
</Style>
</dxg:GridControl.Resources>
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="ProductName"
CellStyle="{StaticResource customCellStyle}">
Product
</dxg:GridColumn>
<dxg:GridColumn FieldName="UnitPrice">
Unit Price
</dxg:GridColumn>
<dxg:GridColumn FieldName="UnitsOnOrder">
Units On Order
</dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView AutoWidth="True" />
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
</Window>

技术:.NET

平台:WPF

产品:DXGrid(包含在DevExpress WPF套包中)

本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/288.html
在线
客服
微信
QQ 电话
023-68661681
返回
顶部