views:

111

answers:

1

I have a got a small issue with the wpf project I am currently working on. I am new to WPF. In my app.xaml I am using the Microsoft Aero theme for my application. I have got something like this in my app.xaml

 <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component/themes/Aero.NormalColor.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

Now what I would like to know how to override certain style properties e.g. For Buttons I want to override the font style meanwhile retaining the rest of the aero style.

If I define a style for button in my window resources e.g.

 <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}" x:Key="RedTextBasedOnButton">
            <Setter Property="Foreground" Value="Red" />
        </Style>

and define a button based on the above style

the button looses all the aero style properties. I think the problem is to do with the way I define the BasedOn property for the style

BasedOn="{StaticResource {x:Type Button}}"

I don't think the resource is static as it comes from a dll, it should probably be something like this. Not sure though.

BasedOn="{DynamicResource {x:Type Button}}"

but the above throws exception and what if I had multiple resourcedictionary in my app.xaml e.g. luna and classic. How can I tell which one to use as the default and at the sametime using and overriding another (e.g. luna) specifically for certain controls in my ui? So some of my buttons will be based on luna style and some on aero style with some further modifications?

Any idea?

Regards,

+1  A: 

just have a look at this link

http://stackoverflow.com/questions/2901664/how-do-i-alter-the-default-style-of-a-button-without-wpf-reverting-from-aero-to-c

http://stackoverflow.com/questions/1780817/wpf-override-standard-theme-in-app-xaml

Kishore Kumar
another one http://stackoverflow.com/questions/2377055/override-overriden-wpf-theme
nabeelfarid