Style definition cann't be found RRS feed

  • 问题

  • I want to put my own style definitions in a xaml file, not the StardardStyles.xaml. So I add a 'ResourceDictionary' type file named CustomStyles.xaml under Common folder, then I paste my style definitions under CustomStyles.xaml, like below:

    <ResourceDictionary xmlns="" xmlns:x=""> <Style x:Key="CustomAppBarButtonStyle" TargetType="Button"> ... </Style> </ResourceDictionary>

    In my MainPage.xaml:

    <Button Width="Auto" Height="Auto" Style="{StaticResource CustomAppBarButtonStyle}"/>

    However, this way doesn't working. It seems that styles in CustomStyles.xaml aren't found by the compiler.
    Only styles in StarndardStyles.xaml are recognized.

    2012年8月2日 6:44


  • This problem is solved. what I should do is add the reference in App.xaml:

    <ResourceDictionary Source="Common/CustomStyles.xaml"/>

    • 已标记为答案 Quarkwp 2012年8月2日 7:08
    2012年8月2日 7:08