there are several ways to achieve this:
1.) provide a property in your databound object that holds an Uri you can easyly bind to
2.) use the Binding's
StringFormat-property[
^]
3.) use a custom
value converter[
^]:
namespace WpfApplication1 {
[ValueConversion(typeof(object), typeof(String))]
public class StringFormatConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
var formatString = string.IsNullOrEmpty(FormatString)? "{0}" : FormatString;
return string.Format(culture, FormatString, value);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
throw new NotImplementedException();
}
public string FormatString{ get; set; }
}
}
}
define an instance inside your xaml:
<Window xmlns:local="clr-namespace:WpfApplication1">
<Window.Ressources>
<local:StringFormatConverter x:key="imageSourceConverter" FormatString="p:\Folder\subfolder\{0}.jpg" />
</Window.Ressources>
<Image Source="{Binding Varenr, Converter={StaticResource imageSourceConverter}}" />