I have a Textblock which Text attribute is binding to a DateTime? type data, and I want to show something when the DateTime? data is null.
The code below works great.<
I don't see any way to do that with TargetNullValue. As a workaround, you can try using a converter:
public class NullValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null)
{
return value;
}
var resourceName = (string)parameter;
return AppResources.ResourceManager.GetString(resourceName);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Then add it to the resources of your page:
Finally, use it instead of TargetNullValue: