Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Style in Application.Resources on All Windows

Closed Thread
 
Thread Tools Display Modes
Old 05-01-2006   #1 (permalink)
Stefc
Guest


 

Style in Application.Resources on All Windows

I try to give all my Windows the same background. To do this I think I
should set a style in the Application.Resources with TargetType = "{x:Type
Window}". This won't work, the background isn't set.

If I use the concrete types of my windows it works as expected. But I must
set for each Window class a style. Better would be that one global setting
on this.

<Style TargetType="{x:Type local:MainWindow}">

<Setter Property="Background" Value="{StaticResource WindowBackground}"/>

</Style>

<Style TargetType="{x:Type dlgs:AboutDialog}">

<Setter Property="Background" Value="{StaticResource WindowBackground}"/>

</Style>

Why the following Code not work ?

<Style TargetType="{x:Type Window}">

<Setter Property="Background" Value="{StaticResource WindowBackground}"/>

</Style>

"MainWindow" and either "AboutDialog" are descendants of Window ???

- Mfg Stefc-


Old 05-01-2006   #2 (permalink)
viliescu
Guest


 

RE: Style in Application.Resources on All Windows

It's because the unnamed styles apply only to the type specified in the
TargetType, it will not affect derived types. I don't know what is the
rationale behind this design decision but this is the way it works.
--
Valentin Iliescu [MVP - Client Application Development]


"Stefc" wrote:

> I try to give all my Windows the same background. To do this I think I
> should set a style in the Application.Resources with TargetType = "{x:Type
> Window}". This won't work, the background isn't set.
>
> If I use the concrete types of my windows it works as expected. But I must
> set for each Window class a style. Better would be that one global setting
> on this.
>
> <Style TargetType="{x:Type local:MainWindow}">
>
> <Setter Property="Background" Value="{StaticResource WindowBackground}"/>
>
> </Style>
>
> <Style TargetType="{x:Type dlgs:AboutDialog}">
>
> <Setter Property="Background" Value="{StaticResource WindowBackground}"/>
>
> </Style>
>
> Why the following Code not work ?
>
> <Style TargetType="{x:Type Window}">
>
> <Setter Property="Background" Value="{StaticResource WindowBackground}"/>
>
> </Style>
>
> "MainWindow" and either "AboutDialog" are descendants of Window ???
>
> - Mfg Stefc-
>
>
>

Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Font Size - XP style vs Vista style John M. Dlugosz Vista General 0 02-24-2008 12:46 AM
Font Size - XP style vs Vista style John M. Dlugosz Vista General 0 02-19-2008 06:48 PM
Font Size - XP style vs Vista style John M. Dlugosz Vista General 1 02-19-2008 09:57 AM
Windows Application vs XAML Browser Application Denis Avalon 0 04-20-2007 01:43 AM
How to change Style at runtime in application-level HolaMan Avalon 5 02-14-2006 05:19 AM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50