This is a migrated thread and some comments may be shown as answers.

Changing window colour

1 Answer 204 Views
RibbonView and RibbonWindow
This is a migrated thread and some comments may be shown as answers.
band
Top achievements
Rank 1
band asked on 19 Jan 2017, 04:24 PM
Hi, I'm utilizing telerik's window 8 theme on the windows. But sometimes I would like to display the window as red to indicate it as an error. I would do the follow

Windows8Palette.Palette.AccentColor = Color.FromArgb(0xFF, 0xE0, 0x00, 0x00);

The issue with doing this is that I always have to change it back to the original colour after the window is shown. Any tips on a "better" way to do this. 

Windows8Palette.Palette.AccentColor = Color.FromArgb(0xFF, 0xE0, 0x00, 0x00);
 
RadWindow.Alert(new DialogParameters
{
    Content = new TextBlock { Text = message, MinWidth = 200, MaxWidth = 450, TextWrapping = TextWrapping.Wrap },
    Header = header,
    Theme = new Windows8Theme(),
    Owner = Application.Current.MainWindow
});
 
Windows8Palette.Palette.AccentColor = AppConfiguration.DefaultBlue;
return header;

1 Answer, 1 is accepted

Sort by
0
Lance | Senior Manager Technical Support
Telerik team
answered on 23 Jan 2017, 10:20 PM
Hello Band,

You can just store the color in a local variable before making the change. Then when you want to restore it, set the AccentColor using the variable.

Here's an example of the approach:
// store the current color
var oldColor = Windows8Palette.Palette.AccentColor;
 
// Makes your change
Windows8Palette.Palette.AccentColor = Color.FromArgb(0xFF, 0xE0, 0x00, 0x00);
 
// show alert
 
// set it back to the original color
Windows8Palette.Palette.AccentColor = oldColor;
 
return header;

I've attached a small demo with two buttons:

1 - One button shows a red alert, click this first
2 - One button shows a normal alert, click this second. 

You'll see that after using the red alert button, the AccentColor is back to default.

Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
RibbonView and RibbonWindow
Asked by
band
Top achievements
Rank 1
Answers by
Lance | Senior Manager Technical Support
Telerik team
Share this question
or