Bug 27739 - Content Property for Page.Resources Does Not Work As Expected
Summary: Content Property for Page.Resources Does Not Work As Expected
Status: RESOLVED INVALID
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.5
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-03-06 15:49 UTC by Michael
Modified: 2015-05-20 07:35 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Michael 2015-03-06 15:49:29 UTC
Hello,

There appears to be a discrepancy between how Xamarin.Forms Xaml treats ResourceDictionaries, and how WPF/Silverlight treats them.

Please see this line (WindowsPhone/Silverlight):
https://github.com/Michael-DST/Stash/blob/master/Xamarin.Forms.Markup/Xamarin.Forms.Markup/Xamarin.Forms.Markup.WinPhone/App.xaml#L10

And this one:
https://github.com/Michael-DST/Stash/blob/master/Xamarin.Forms.Markup/Xamarin.Forms.Markup/Xamarin.Forms.Markup/ResourceDictionaryExample.xaml#L7

You can see that both resources are defined the same way.  However, in Xamarin.Forms, the property is serialized as a string and attempts to assign this to the Resources property, and throws an exception.

Launching the Windows Phone project will throw the exception here:
https://github.com/Michael-DST/Stash/blob/master/Xamarin.Forms.Markup/Xamarin.Forms.Markup/Xamarin.Forms.Markup.WinPhone/App.xaml.cs#L32

Please let me know if you have any questions around this, or if I can assist in any additional way.

Thank you,
Michael
Comment 1 Stephane Delcroix 2015-05-20 06:44:55 UTC
Michael,

In Xamarin.Forms, ContentPage.Resources is null by default, and you have to create the ResourceDictionary before being able to add items to it.

	<ContentPage.Resources>
		<ResourceDictionary>
			<x:String x:Key="KeyName">Hello World!</x:String>
		</ResourceDictionary>
	</ContentPage.Resources>