I have this legacy database for which I'm building a custom viewer using Linq to Sql.
Now some of the fields in a table can have the value NULL. Using normal databinding in a DataTemplate (typed for the Class generated by the ORM Designer)
<TextBlock Text="{Binding Path=columnX}"/>
If columnX has value NULL, nothing is displayed. (It seems the to be the WPF convention) I'd like to display "NULL" instead if the value is NULL. (equivalent to column_value ?? "NULL"
)
I could use a converter as in
<TextBlock Text="{Binding Path=columnX, Converter={StaticResource nullValueConverter}}"/>
Converter class
class NullValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null)
return "NULL";
...
But this seems like too much work. Also this logic would need to be duplicated in existing non-trivial converters..
Is there a quick-hit way to accomplish this?