我正在创建一个 WPF 窗口并在其中加载一个用户控件,如下所示:
Uri uri = new Uri("Views/ApplicationInfo.xaml", UriKind.RelativeOrAbsolute);
UserControl versionInfoUserControl = (UserControl)Application.LoadComponent(uri);
#region Initizalizing the Window, Winodw Proporties and Icon
Window versionWindow = new Window();
versionWindow.Height = 250;
versionWindow.Width = 400;
versionWindow.ResizeMode = ResizeMode.NoResize;
现在,当我尝试添加如下应用程序图标时:
versionWindow.Icon = new BitmapImage(new Uri(@"pack://application:,,component/Images/Ico.png"));
我收到 URI 前缀无法识别错误。
*我是否需要使用应用程序名称更改应用程序,例如:
versionWindow.Icon = new BitmapImage(new Uri(@"pack://MyApp.MVVM.WPF:,,component/Images/Ico.png"));
即使那样我也遇到同样的错误