I start with Windows 8 C # sample user and XAML user controls and move files
Themes/Generic.xaml BasicCustomControl.cs BasicUserControl.xaml BasicUserControl.xaml.cs ImageWithLabelControl.cs
to the Metro class library called Controls , refer to it in the UserAndCustomControls project and correct the local:... links to xmlns:local="using:Controls" . This works great.
BUT, if you create the "Style.xaml" resource library in the class library using
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Controls"> <Color x:Key="ColorBackground">Red</Color> </ResourceDictionary>
and include in the file ScenarioList.xaml
<Page.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Controls;component/Style.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Page.Resources>
I get a runtime error
XamlParseException Failed to assign to property 'Windows.UI.Xaml.ResourceDictionary.Source'.
if I try to apply color to the grid
<Grid> <Grid.Background> <SolidColorBrush Color="{StaticResource ColorBackground}" /> </Grid.Background> <ListBox x:Name="Scenarios" ... [...] </Grid>
[Q] The question is, how do I correctly declare, reference and use the external style in a Metro application? My idea is to create reusable controls and common styles that come as a single dll file.
source share