I\'m trying to set FallbackValue in case when my converter cannot be call, but I\'m not sure how to do that.
For myself, I created the following example:
pack://application:,,,/NotFound.png
pack://application:,,,/NullImage.png
The path to the images, I announced in resources. Images are stored in the root of the project. Listing of MyTestData
:
public class TestDataForImage : DependencyObject
{
public string NotFoundString
{
get
{
return (string)GetValue(NotFoundStringProperty);
}
set
{
SetValue(NotFoundStringProperty, value);
}
}
public static readonly DependencyProperty NotFoundStringProperty = DependencyProperty.Register("NotFoundString", typeof(string), typeof(TestDataForImage), new PropertyMetadata(""));
public string NullString
{
get
{
return (string)GetValue(NullStringProperty);
}
set
{
SetValue(NullStringProperty, value);
}
}
public static readonly DependencyProperty NullStringProperty = DependencyProperty.Register("NullString", typeof(string), typeof(TestDataForImage), new PropertyMetadata(""));
public TestDataForImage()
{
NotFoundString = "pack://application:,,,/NotExistingImage.png";
NullString = null;
}
}