我正在创建一个应用程序,我更改了我的HyperlinkButton图像,但它没有。
var brush = new ImageBrush();
brush.ImageSource = new BitmapImage(new Uri("/Pics/Test/1/1_10.png", UriKind.Relative));
MainButton.Background = brush;
我将此代码放在click事件方法中,但调试器在第二行之后执行此代码:
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
#endif
答案 0 :(得分:1)
我认为由于URI无效,您可能会遇到异常。在这里查看URI方案:https://msdn.microsoft.com/en-us/library/windows/apps/jj655406.aspx
此外,图像应添加为内容。