c# - Change background color of parent form -


i have been looking couple of days answer , couldn't find one. have c# wpf application i'm displaying pc time, when click on application opens wpf form want edit background of main form background far have this:

    mainwindow mainwindow = new mainwindow();     private void buttonsave_click(object sender, routedeventargs e)     {         mainwindow.background = new solidcolorbrush(color.fromrgb((byte)sliderred.value, (byte)slidergreen.value, (byte)sliderblue.value));     } 

so far see should fine not editing background. sorry if nub question quite new coding , not find answer question.

thanks in advance

2 options; 1) if wanting change parents forms properties within child form, pass reference through constructor. 2) , more common appears "dialog" implementation , 1 go more detail on create public property in child form read within parent after child closed.

public class mainform() {      private void buttonsave_click(object sender, routedeventargs e)     {         colorpicker colordialog = new colorpicker();         colordialog.showdialog(); // block until child closed true dialog does.         this.background = colordialog.chosencolor;     } }  public class colorpicker() {     public solidcolorbrush chosencolor{get;private set;}  // write code color picker store value in chosencolor. } 

this basics next step, full implementation make use of dialog result property check if dalog closed or if actual color picked.


Comments

Popular posts from this blog

android - How to save instance state of selected radiobutton on menu -

python 3 IndexError: list index out of range -

IF statement in MySQL trigger -