locked
Windows Store app failed to create style BasedOn shared style

    Question

  • I have a windows 8.1 app.

    In Project.Shared there is ResourceDictionary SharedResources.xaml with base style,

    <Style x:Key="CommonLayerListItemStyle" TargetType="TextBlock">
        <Setter Property="FontFamily" Value="Segoe WP" />
        <Setter Property="Foreground" Value="{StaticResource UnselectBrush}" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
    </Style>

    in Windows Phone app is StyleResources.xaml wiht style based on this

    <Style x:Key="LayerListItemStyle"   
           BasedOn="{StaticResource CommonLayerListItemStyle}"
           TargetType="TextBlock">
        <Setter Property="FontSize" Value="20" />        
    </Style>

    same in Windows app StyleResources.xaml:

    <Style x:Key="LayerListItemStyle"
           BasedOn="{StaticResource CommonLayerListItemStyle}"
           TargetType="TextBlock">
        <Setter Property="FontSize" Value="28" />
        <Setter Property="Margin" Value="42,0,0,0" />
    </Style>

    All styles are used in UserControl created in Shared project. I do this to override FontSize on diffrent platforms.

    I merged all dictionaries in App.xaml

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Styles/SharedResources.xaml" />
        <ResourceDictionary Source="Styles/StyleResources.xaml" />
    </ResourceDictionary.MergedDictionaries>

    But my app does not start with Unhandled exception:

    Cannot find a Resource with the Name/Key CommonLayerListItemStyle [Line: 10...

    Why does this happens?



    • Edited by XakPC Monday, March 02, 2015 1:43 PM
    Monday, March 02, 2015 1:40 PM

Answers