J'ai créé un nouveau Windows Phone 8 (Silverlight) du projet. Ajouté Thèmes dossier, ajouté deux dictionnaires de ressources dans ce dossier, un contenant solidcolorbursh et un contenant couleurs.Impossible de trouver une ressource avec le nom/clé dans Windows Phone 8 projet
Je fusionné ces deux dictionnaires de ressources dans App.xaml
En MainPage.xaml je un solidcolorbursh à fond de la grille.
extraits de code:
App.xaml:
<Application.Resources>
<ResourceDictionary x:Key="mainStyle">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/resTest;component/Themes/MyColors.xaml"></ResourceDictionary>
<ResourceDictionary Source="/resTest;component/Themes/MyStyles.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<local:LocalizedStrings xmlns:local="clr-namespace:resTest" x:Key="LocalizedStrings"/>
</ResourceDictionary>
</Application.Resources>
MainPage.xaml:
<Grid x:Name="LayoutRoot" Background="{StaticResource RedSolidColorBrush}">
</Grid>
MyColors.xaml:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Color x:Key="RedColor">#FFFF0000</Color>
</ResourceDictionary>
MyStyles.xaml:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<SolidColorBrush x:Key="RedSolidColorBrush" Color="{StaticResource RedColor}"></SolidColorBrush>
</ResourceDictionary>
Exception levée:
Blockquote
'System.Windows.Markup.XamlParseException' in System.Windows.ni.dll Its showing runtime error:
Exception thrown: 'System.Windows.Markup.XamlParseException' in System.Windows.ni.dll
Additional information: Cannot find a Resource with the Name/Key RedColor [Line: 14 Position: 44]
Où suis-je tort?
Références: https://msdn.microsoft.com/en-us/library/cc903952(VS.95).aspx
Referencing a merged resource dictionary in windows phone seven failing