0
我必須聲明如下成像路徑:爲什麼要Image.Source結合圖像路徑不以這種方式工作
public static string _edit_vector32 = "pack://application:,,,/Resources/Images/Icons/32/edit-vector2-32.png";
我嘗試添加一個簡單的屬性,它返回一個ImageSource的到我的視圖模型如下:
public ImageSource ClockImage
{
get
{
return new BitmapImage(new Uri(RuntimeSettings._clock24)) as ImageSource;
}
}
然後在XAML綁定:
<Image Source="{Binding ClockImage}"/>
爲什麼這個不行的,而:
<Image Source="pack://application:,,,/Resources/Images/Icons/32/edit-vector2-32.png"/>
按預期工作?
第一個案例也應該工作,你確定你綁定到正確的屬性?也許datacontext是不同的,因爲封閉元素的綁定? – Domysee