c# - WPF XAML 解析异常发生错误?

标签 c# wpf xaml mvvm

 <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/

相关文章:

c# - 多客户端 Web 应用程序设计

C# WPF - 如何组合数据触发器和触发器?

c# - 我的菜单中的图标显示太大。我怎样才能让它适合小方 block ?

c# - 在WPF中使用System.Drawing.Color设置背景和前景

c# - 在表格单元格的右下角显示标签

c# - 确保字符串不包含特定字符的快速方法

wpf - 在 ListBox 中查找控件?

c# - 如何在 C# 注释中添加 xaml 代码?

c# - 如何在 Windows 8.1 应用程序 xaml 中的 MenuFlyoutItem 内添加 StackPanel

c# - 为什么我不能将 DynamicResource 与 DataGridColumn.CellStyle 一起使用