I'm working on a WPF application and I'm working with a Telerik dialog control that displays like a Window but is not actually a Window object.
Since it's not an actual Window (but it looks and acts like one) it's style doesn't match the rest of dialogs used in my application.
So, I have created a template for this dialog and I am in the process of assigning System colors to the template so that the dialog uses the same colours and has the same look and feel as a normal Window.
For some reason I cannot find the System Color for the "Window Color" (not the window background color, that one's pretty easy to find...I'm talking about the actual window color...the frame and header of the window)
I have gone through all of the System.Windows.SystemColors but can't find the system color that defines the "Window Color"... like I said, I don't want a reference to the "window's background color".
I was wondering if anyone knew about how to retrieve this color.
Edit: Here is some code that I have implemented in my attempts to determine which system color is used for the Window Color.
The following WPF code is a bunch of Borders whose backgrounds are set to each System Color available...a TextBlock with the name of the System Color is within each Border.
If you want to check it out for yourself, put the following into a Window or something so that you can see it:
<ScrollViewer>
<StackPanel>
<-- here I had another Stack Panel referencing the Brushes
instead of using the Keys. I wanted the application to be dynamic
so that if the user changed colors it would be reflected in
the application on the fly...-->
<StackPanel>
<StackPanel.Resources>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="White" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="4" Color="Black" ShadowDepth="0"/>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="Border">
<Setter Property="BorderBrush" Value="Red"/>
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Margin" Value="2"/>
<Setter Property="Height" Value="20"/>
</Style>
</StackPanel.Resources>
<Border>
<Border.Background>
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.WindowColorKey}}"/>
</Border.Background>
<TextBlock Text="SystemColors.WindowColorKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" >
<TextBlock Text="SystemColors.ActiveBorderBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.ActiveCaptionBrushKey}}" >
<TextBlock Text="SystemColors.ActiveCaptionBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.ActiveCaptionTextBrushKey}}" >
<TextBlock Text="SystemColors.ActiveCaptionTextBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.AppWorkspaceBrushKey}}" >
<TextBlock Text="SystemColors.AppWorkspaceBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" >
<TextBlock Text="SystemColors.ControlBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" >
<TextBlock Text="SystemColors.ControlDarkBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" >
<TextBlock Text="SystemColors.ControlDarkDarkBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" >
<TextBlock Text="SystemColors.ControlLightBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}" >
<TextBlock Text="SystemColors.ControlLightLightBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" >
<TextBlock Text="SystemColors.ControlTextBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.DesktopBrushKey}}" >
<TextBlock Text="SystemColors.DesktopBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.GradientActiveCaptionBrushKey}}" >
<TextBlock Text="SystemColors.GradientActiveCaptionBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.GradientInactiveCaptionBrushKey}}" >
<TextBlock Text="SystemColors.GradientInactiveCaptionBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" >
<TextBlock Text="SystemColors.GrayTextBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" >
<TextBlock Text="SystemColors.HighlightBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" >
<TextBlock Text="SystemColors.HighlightTextBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.HotTrackBrushKey}}" >
<TextBlock Text="SystemColors.HotTrackBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.InactiveBorderBrushKey}}" >
<TextBlock Text="SystemColors.InactiveBorderBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.InactiveCaptionBrushKey}}" >
<TextBlock Text="SystemColors.InactiveCaptionBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.InactiveCaptionTextBrushKey}}" >
<TextBlock Text="SystemColors.InactiveCaptionTextBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.InfoBrushKey}}" >
<TextBlock Text="SystemColors.InfoBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.InfoTextBrushKey}}" >
<TextBlock Text="SystemColors.InfoTextBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.MenuBrushKey}}" >
<TextBlock Text="SystemColors.MenuBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.MenuBarBrushKey}}" >
<TextBlock Text="SystemColors.MenuBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.MenuHighlightBrushKey}}" >
<TextBlock Text="SystemColors.MenuHighlightBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}" >
<TextBlock Text="SystemColors.MenuTextBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.ScrollBarBrushKey}}" >
<TextBlock Text="SystemColors.ScrollBarBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" >
<TextBlock Text="SystemColors.WindowBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" >
<TextBlock Text="SystemColors.WindowFrameBrushKey" />
</Border>
<Border Background="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" >
<TextBlock Text="SystemColors.WindowTextBrushKey" />
</Border>
</StackPanel>
</StackPanel>
</ScrollViewer>
Thanks for your help
Edit: Here is the VB.NET version of the C# solution posted. You can bind to the WindowColorBrush property to set things like the Background color of controls in your WPF styles:
Public Class WindowsBackgroundRetriever
Implements System.ComponentModel.INotifyPropertyChanged
<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> _
Public Structure DWMCOLORIZATIONPARAMS
Public ColorizationColor As UInt32
Public ColorizationAfterglow As UInt32
Public ColorizationColorBalance As UInt32
Public ColorizationAfterglowBalance As UInt32
Public ColorizationBlurBalance As UInt32
Public ColorizationGlassReflectionIntensity As UInt32
Public ColorizationOpaqueBlend As UInt32
End Structure
Private cParams As New DWMCOLORIZATIONPARAMS
<Runtime.InteropServices.DllImport("dwmapi.dll", EntryPoint:="#127")> _
Private Shared Sub DwmGetColorizationParameters(ByRef dp As DWMCOLORIZATIONPARAMS)
End Sub
Private _windowColor As Color
Public Property WindowColor As Color
Get
Return _windowColor
End Get
Set(ByVal value As Color)
_windowColor = value
RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs("WindowColor"))
End Set
End Property
Private _windowColorBrush As SolidColorBrush
Public Property WindowColorBrush As SolidColorBrush
Get
If _windowColorBrush Is Nothing Then
_windowColorBrush = New SolidColorBrush(WindowColor)
End If
Return _windowColorBrush
End Get
Set(ByVal value As SolidColorBrush)
_windowColorBrush = value
RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs("WindowColorBrush"))
End Set
End Property
Public Sub New()
DwmGetColorizationParameters(cParams)
Dim r = BitConverter.GetBytes(cParams.ColorizationColor >> 16)
Dim g = BitConverter.GetBytes(cParams.ColorizationColor >> 8)
Dim b = BitConverter.GetBytes(cParams.ColorizationColor)
WindowColor = Color.FromArgb(BitConverter.GetBytes(255)(0), r(0), g(0), b(0))
End Sub
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
End Class