<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
x:Class="AFICController.EULA"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:res="clr-namespace:AFICController.Resources"
Title="{x:Static res:Strings.WizardWelcomeWindow_Title}"
Width="800"
Height="600"
WindowStartupLocation="CenterScreen"
Icon="/AFICController;Component/Resources/Images/att_icon.ico"
ResizeMode="NoResize">
我正在开发 C# WPF 应用程序,我正在使用 MVVM 实现它。我的应用程序首先显示启动画面,看起来很好,但之后我想要 EULA(最终用户许可协议(protocol))窗口,当我尝试执行它时显示异常通过定位到上述代码,作为“XAML Parse Exception“在'System.Windows.Markup.StaticExtension'上提供值抛出异常”。
以下是我调用 EULA 的 C# 代码。请帮助我,因为我已经尝试了所有方法来删除此异常。?
class App : Application
{
[STAThread()]
static void Main()
{
Splasher.Splash = new SplashScreen();
Splasher.ShowSplash();
Mouse.OverrideCursor = null;
for (int i = 0; i < 5000; i++)
{
Thread.Sleep(1);
}
Splasher.CloseSplash();
new App();
}
/// <summary>
///
/// </summary>
public App()
{
App.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri(@"\Resources\Dictionary\ATTColors.xaml", UriKind.Relative) });
App.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri(@"\Resources\Dictionary\AppButton.xaml", UriKind.Relative) });
Console.WriteLine("EULA Opened");
StartupUri = new System.Uri("EULA.xaml", UriKind.Relative);
//StartupUri = new System.Uri("View/WizardDialog.xaml", UriKind.Relative);
Run();
}
最佳答案
鉴于你的错误:
"XAML Parse Exception "Provide value on 'System.Windows.Markup.StaticExtension' threw an exception"
我认为你的问题在于这一行:
Title="{x:Static res:Strings.WizardWelcomeWindow_Title}"
这是使用 StaticExtension
的地方。
通过转到其属性并检查自定义工具是否设置为 PublicResXFileCodeGenerator
(而不是 ResXFileCodeGenerator
),确保您的 Strings.resx
是公开的>,这是默认设置)- 您可以直接在那里编辑它,也可以在打开资源文件时通过设计器中的 Access Modified
组合框进行编辑。
关于c# - WPF XAML 解析异常发生错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21400026/