![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| 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- |
| | #2 (permalink) |
| 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- > > > |
| |
| |
![]() |
| 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 |