Good afternoon, I'm starting in the world of programming in C # in WPF platform and I have a question and hopefully could help me ..
How I can change the color of the windows of my application? Allowing the user to choose between several colors and according to the color chosen the windows color change.
I appreciate them so much that they could help me.
VulpesPosted Oct 30, 2014, 2:43 PM
To do that, you'll first need to add references to System.Windows.Forms.dll and System.Drawing.dll to your project.
If you then want the user to be able to change the color of the CURRENT window on (say) a button click, the following code should work:
// change background to color selected by user
this.Background = scb;
with this :
foreach(Window w in Application.Current.Windows) w.Background = scb;
However, if you open or reopen any more windows, you'll need to remember to change the Background property before they're displayed.
MahaPosted Nov 3, 2014, 4:01 AM
MahaPosted Oct 31, 2014, 2:22 PM
Mahesh ChandPosted Oct 31, 2014, 2:11 PM
MahaPosted Oct 31, 2014, 1:21 PM
I have sent many emails to you people about this problem, but no reply. Please look into this matter.
VulpesPosted Oct 31, 2014, 12:04 PM
internal static SolidColorBrush CommonBackground;
public MainWindow()
{
InitializeComponent();
CommonBackground = (SolidColorBrush)this.Background;
}
// ....
if (dr == System.Windows.Forms.DialogResult.OK) {
var smc = System.Windows.Media.Color.FromArgb(cd.Color.A, cd.Color.R, cd.Color.G, cd.Color.B);
scb = new SolidColorBrush(smc);
this.Background = scb;
//foreach (Window w in Application.Current.Windows) w.Background = scb;
CommonBackground = scb;
}
You could then access it from any other window in the application using the expression MainWindow.CommonBackground.
If you wanted to save it between application sessions, you'd have to save the ARGB components (say) to a text file and then load that, reconstruct the SoildColorBrush and set the static property the next time the application was run.
Mahesh ChandPosted Oct 31, 2014, 11:47 AM
Mahesh ChandPosted Oct 31, 2014, 11:47 AM
Roman BadilloPosted Oct 31, 2014, 11:39 AM
Roman BadilloPosted Oct 31, 2014, 11:33 AM
Shweta LodhaPosted Oct 30, 2014, 2:27 PM