There is no way to achieve what you want without any meaningful code. The easiest solution, as you already thought, is to use a converter. It is true that this requires data binding, so this is not a pure static value for the source property. However, since the static value of the source property is simply already a problem, this is hardly the reason to avoid the approach. Here is my preferred solution: -
Converter: -
public class BaseUriConverter : IValueConverter
{
private Uri myBaseUri;
public BaseUriConverter()
{
myBaseUri = new Uri(Application.Current.Host.Source.AbsoluteUri);
}
public string AdjustPath { get; set; }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Uri uri = new Uri(myBaseUri, AdjustPath);
Uri result = new Uri(uri, (string)parameter);
return result.ToString();
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException("This converter only works for one way binding");
}
}
In a resource in App.Xaml: -
<local:BaseUriConverter x:Key="BaseUri" AdjustPath=".." />
, ".." . Xap Clientbin . , , , Visual Studio IIS.
- : -
<Image DataContext="0" Source="{Binding Converter={StaticResource BaseUri}, ConverterParameter='images/Test.jpg' }" />
, DataContext , , , , . .
baseURL AdjustPath , , , , .