您應該使用Converter
這將追加這些字符串:
public class ImagePathConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parametr, CultureInfo culture)
{
var imgPath = "./Images/{0}";
return string.Format(imgPath, value);
}
public object ConvertBack(object value, Type targetType, object parametr, CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
和xaml
:
<Page.Resources>
<converters:ImagePathConverter x:Key="imagePathConverter"/>
...
</Page.Resources>
...
<HyperlinkButton Content="Preview" NavigateUri="{Binding image_value, Converter={StaticResource imagePathConverter}}" TargetName="_blank" />
* 我建議不要硬編碼路徑,但把它放到資源文件中,這將給更多的靈活性。
所以,什麼問題呢? –