2014-01-28 68 views
3
<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"> 

我正在使用MVVM。我的應用程序首次顯示啓動屏幕,看起來不錯,但之後我希望EULA(最終用戶許可協議)窗口,當我嘗試執行它時,顯示了一個C#WPF Applcation作爲「XAML解析異常」的異常在'System.Windows.Markup.StaticExtension'上提供值拋出異常「通過定位到上述代碼。WPF XAML解析異常發生錯誤?

以下是我從哪裏打電話給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(); 
} 

回答

17

鑑於你的錯誤:

"XAML Parse Exception "Provide value on 'System.Windows.Markup.StaticExtension' threw an exception"

我覺得你的問題就出在這行:

Title="{x:Static res:Strings.WizardWelcomeWindow_Title}" 

這是使用StaticExtension地方。

確保您Strings.resx是公衆通過將它的屬性和檢查自定義工具設置爲PublicResXFileCodeGenerator(而不是ResXFileCodeGenerator,這是默認設置) - 您可以直接對它進行編輯或通過在該Access Modified組合框設計師打開資源文件時。

+0

是的,它的工作感謝:) – TheSpy

+0

但它會產生另一個錯誤,如下所示:「與指定的綁定約束匹配的類型'AFICController.EULA'的構造函數的調用引發異常。 – TheSpy

+0

任何人都有這個想法? – TheSpy