WPF: reverting brush to default/original

前端 未结 5 822
不知归路
不知归路 2021-02-05 03:10

I\'m a complete newbie at WPF.

At the moment I\'m making a usercontrol for form elements called \"LabeledTextbox\" which contains a label, a textbox and a textblock for

5条回答
  •  孤城傲影
    2021-02-05 03:24

    Just store the default settings. Here a code excample.

            System.Windows.Media.Brush save;
    
            private void Window_Loaded(object sender, RoutedEventArgs e)
                    {
              //Store the default background 
            save = testButton.Background;
    
            }
    
    
            private void ChangeBackground(){
    
            testButton.Background = Brushes.Red;
    
            }
    
            private void restoreDefaultBackground(){
    
            //Restore default Backgroundcolor
    
            testButton.Background = save;
    
            }
    

提交回复
热议问题