Hi,
In my small WPF program I want to show the name of the "background color" of the client area on a mouse click in am message box .... How can I do it?
System : Win7(32-bit)/VS2008
Thanks.
Hi,
In my small WPF program I want to show the name of the "background color" of the client area on a mouse click in am message box .... How can I do it?
System : Win7(32-bit)/VS2008
Thanks.
You need to get the Background object of the element you want to get the color for. Do this in your mouse click event like this:
NOTE: You must check for which brush type, basically SolidColorBrush would only really apply as a gradient would not be a simple color.
EXAMPLE: Brush backgroundColor = LayoutRoot.Background;
if (backgroundColor is SolidColorBrush)
{
string colorValue = ((SolidColorBrush)backgroundColor).Color.ToString();
}