开发者

Silverlight. Cannot set base style from other xaml resources

I need to create resource with name OkButtonStyle based on RedButtonStyle. But i have resource with key not found exception. What i am doing wrong? I have two resouce dictionaries. One baseStyles.xaml where RedButtonStyle located and styles.xaml where i need to locate my okbuttonstyle but all my efforts results nothing.

App.xaml

     <ResourceDictionary.MergedDictionaries>
            <ResourceDict开发者_如何学编程ionary Source="baseStyles.xaml" />
            <ResourceDictionary x:Name="currentTheme" Source="styles.xaml" />

        </ResourceDictionary.MergedDictionaries>

styles.xaml

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="baseStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style x:Key="OkButtonStyle"
       BasedOn="RedButtonStyle"
       TargetType="Button">
</Style>

baseStyles.xaml

<Style x:Key="RedButtonStyle" TargetType="Button"> ...properties... </Style>


Instead of using the syntax:

<Style BasedOn="RedButtonStyle" ...

use the syntax:

<Style BasedOn="{StaticResource RedButtonStyle}" ...

The Style.BasedOn property is not the name of the other style it is based on, it is the style it is based on.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜