Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WPF XAML分析异常发生错误?_C#_Wpf_Xaml_Mvvm - Fatal编程技术网

C# WPF XAML分析异常发生错误?

C# WPF XAML分析异常发生错误?,c#,wpf,xaml,mvvm,C#,Wpf,Xaml,Mvvm,我正在开发一个C#WPF应用程序,我正在使用MVVM实现它。我的应用程序最初显示启动屏幕,看起来很好,但之后我希望在尝试执行时显示一个EULA(最终用户许可协议)窗口,该窗口显示一个异常,即“XAML解析异常”在“System.Windows.Markup.StaticExtension”上提供值引发了一个异常“通过定位上述代码 以下是我调用EULA的C#代码。请帮助我,因为我已经尝试了所有方法来删除此异常 <Window xmlns="http://schemas.microsoft.

我正在开发一个C#WPF应用程序,我正在使用MVVM实现它。我的应用程序最初显示启动屏幕,看起来很好,但之后我希望在尝试执行时显示一个EULA(最终用户许可协议)窗口,该窗口显示一个异常,即“XAML解析异常”在“System.Windows.Markup.StaticExtension”上提供值引发了一个异常“通过定位上述代码

以下是我调用EULA的C#代码。请帮助我,因为我已经尝试了所有方法来删除此异常

 <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">
class应用程序:应用程序
{
[STAThread()]
静态void Main()
{
Splasher.Splash=新的SplashScreen();
Splasher.ShowSplash();
Mouse.OverrideCursor=null;
对于(int i=0;i<5000;i++)
{
睡眠(1);
}
splash.CloseSplash();
新应用程序();
}
/// 
/// 
/// 
公共应用程序()
{
App.Current.Resources.MergedDictionaries.Add(新资源字典{Source=newURI(@“\Resources\Dictionary\ATTColors.xaml”,UriKind.Relative)});
App.Current.Resources.MergedDictionaries.Add(新资源字典{Source=newURI(@“\Resources\Dictionary\AppButton.xaml”,UriKind.Relative)});
控制台写入线(“EULA打开”);
StartupUri=new System.Uri(“EULA.xaml”,UriKind.Relative);
//StartupUri=new System.Uri(“View/WizardDialog.xaml”,UriKind.Relative);
Run();
}
鉴于您的错误:

“XAML解析异常”在“System.Windows.Markup.StaticExtension”上提供值时引发异常”

我认为你的问题在于这一行:

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();
}
这就是使用
StaticExtension
的地方


通过转到其属性并检查自定义工具是否设置为
PublicResXFileCodeGenerator
(而不是
ResXFileCodeGenerator
,这是默认设置),确保您的
Strings.resx
是公共的-打开资源文件时,您可以直接在那里编辑它,也可以通过设计器中的“Access Modified组合框进行编辑。

但它会生成另一个错误,如下所示:“对与指定绑定约束匹配的'AFICController.EULA'类型调用构造函数时引发异常。“任何人都知道这一点??您应该调试
AFICController.EULA
窗口的构造函数。异常可能会为您提供更多信息。如果您无法解决此问题,我建议您发布一个包含相关代码和异常的新问题。或者您可以将“访问修饰符”更改为“公共”当*.resx在designer中打开时,它具有相同的效果,但(至少对我来说)所涉及的“魔力”更少。你挽救了这一天。谢谢。
Title="{x:Static res:Strings.WizardWelcomeWindow_Title}"