![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | 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- |
My System Specs![]() |
| | #2 (permalink) |
| | 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- > > > |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Font Size - XP style vs Vista style | Vista General | |||
| Font Size - XP style vs Vista style | Vista General | |||
| Font Size - XP style vs Vista style | Vista General | |||
| Windows XP style folders | Vista file management | |||