usercontrol中的WPF数据网格

时间:2012-10-12 09:38:19

标签: wpf

        <DataGrid  Width="auto"  AutoGenerateColumns="False"  Name="dgData" >

        <DataGrid.Columns>
            <DataGridTextColumn Binding="{Binding HODAppID}" Width="75" Header="HOD APPID" />
            <DataGridTextColumn Binding="{Binding Req}"   Header="CandidateID" Visibility="Hidden" />
            <DataGridTextColumn Binding="{Binding Req}"  Header="RequisitionNo" Visibility="Hidden" />
            <DataGridTextColumn Binding="{Binding Candidate}" Width="1.3*" Header="CANDIDATE NAME" />
            <DataGridTextColumn Binding="{Binding Req}" Width="*" MinWidth="200"  Header="REQUIREMENT"/>
            <DataGridTextColumn Binding="{Binding status}" Width="80" Header="Status" />
            <DataGridTextColumn Binding="{Binding daysopen}" Width="120" x:Name="noDays" Header="# of Days Open" />

我有一个数据网格,如上所述,我试图在noNays列中获取单元格值,并根据其中的值更改前面颜色。请在此方面提供帮助。谢谢提前

1 个答案:

答案 0 :(得分:0)

使用IValueConverter创建转换器,并将其添加到noDays列Foreground属性中。转换器应根据daysopen属性的值返回画笔值。

http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx

修改

显然IValueConverter无法直接在DataGridTextColumn上工作。可以在http://social.msdn.microsoft.com/Forums/en/wpf/thread/77a9f317-d0be-4aed-9dc9-9917ad98ffc8找到更多信息和示例。