更改XAML元素的图像

时间:2012-11-20 18:51:06

标签: c# silverlight xaml binding

我正在尝试为我的XAML元素更改图像,但无法弄清楚如何,我正在使用http://www.divelements.co.uk/net/controls/sandribbonsl/的沙带按钮。我知道如何做到这一点?

XAML代码:

<sr:Button x:Name="Print" Text="Print" SmallImage="/Fsc.Feenics.Clients.Silverlight2;component/Images/16/print.png" Size="Small" Activate="Button_Activate" />

(破碎)C#代码:

Print.SmallImage = new BitmapImage(new Uri("/Fsc.Feenics.Clients.Silverlight2;component/Images/16/printOn.png"));

谢谢,
杰森

1 个答案:

答案 0 :(得分:1)

UriKind.RelativeOrAbsolute添加到以下行:

Print.SmallImage = new BitmapImage(
    new Uri("/Fsc.Feenics.Clients.Silverlight2;component/Images/16/printOn.png",
            UriKind.RelativeOrAbsolute));