locked
Resources not working after navigation

    Question

  • I have a multi-page Windows 8.1 app that uses Resources. On the first page (MainPage), I have the following in my Page.Resources section:

    <Page.Resources>
    	<ResourceDictionary>
    		<ResourceDictionary.MergedDictionaries>
    			<ResourceDictionary Source="ms-appx:///UniversalAppExtras/BasicButton.xaml"/>
    			<ResourceDictionary Source="ms-appx:///WindowsAppExtras/PopupResources.xaml"/>
    			<ResourceDictionary Source="ms-appx:///WindowsAppExtras/SettingsResources.xaml"/>
    			<ResourceDictionary Source="ms-appx:///UniversalAppExtras/NoDeleteTextBox.xaml"/>
    			<ResourceDictionary>
    				<!--My Other Resources…-->
    			</ResourceDictionary>
    		</ResourceDictionary.MergedDictionaries>
    	</ResourceDictionary>
    </Page.Resources>
    

    This works fine, all the resources load fine, no errors, all good. Then I call the Navigate method to go to the next Page:

    Me.Frame.Navigate(GetType(EV3Setup))

    Which has the following Resources:

    <Page.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="ms-appx:///UniversalAppExtras/BasicButton.xaml"/> <ResourceDictionary Source="ms-appx:///WindowsAppExtras/PopupResources.xaml"/> <ResourceDictionary Source="ms-appx:///WindowsAppExtras/SettingsResources.xaml"/> <ResourceDictionary> <!--My Other Resources…--> </ResourceDictionary> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Page.Resources>

    And I get the following error message at the InitializeComponent() statement in the New() method of the Page:

    An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in Linebot2015Test.exe but was not handled in user code

    WinRT information: E_RUNTIME_SETVALUE [Line: 12 Position: 25]

    Additional information: The text associated with this error code could not be found.

    E_RUNTIME_SETVALUE [Line: 12 Position: 25]

    If there is a handler for this exception, the program may be safely continued.

    I have been able to determine that this has to do with LoadComponent and my Resources. The thing that is confusing me here is:

    Both pages use the same Resources, so why am I having this problem on the second page but not the first?

    If I remove the Resources, everything seems to work. What can I do to fix this? Thanks.


    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Monday, March 09, 2015 8:54 PM

Answers

  • Please place all the shared resources in App.xaml of the app cause its better to add all in one place and then use everywhere and also chances of errors are very less and in this situation this will solve your problem place them in App.xaml and define them as styles.

    see this

    If found Useful Mark as Answer.

    Muhammad Asad


    Asad

    Monday, March 09, 2015 9:03 PM