Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF datagrid: how to replace null values with 'n/a' automatically?

Tags:

c#

wpf

datagrid

I have a datagrid biding to nullable properties. For null values in DataGridTextColumn, instead of showing empty cell, I'd like to display 'n/a'. Is it possible?

like image 845
newman Avatar asked May 21 '11 19:05

newman


1 Answers

You can use the TargetNullValue Property to set a default text if the binding returns null.

SAMPLE

     <DataGridTextColumn Header="SomeText" Binding="{Binding 
                         MyNullabeProperty,TargetNullValue=N/A}"/>
like image 184
biju Avatar answered Oct 14 '22 20:10

biju