WPF refresh parent window when child window is closed

Refresh the parent window after the child window performs an operation after closing the child window
Parent window:
/// <summary>
        ///pop up
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miFuncSet_Click(object sender, RoutedEventArgs e)
        {
            WinFuncSetting funcSetting = new WinFuncSetting();
            funcSetting.ChangeTextEvent += new ChangeTextHandler(FuncSettingClosed);
            funcSetting.ShowDialog();     
        }
        //Set the method to be executed when the window is closed
        void FuncSettingClosed()
        {
      //Write the method you want to call, such as rebinding the data source, changing the value of a label, etc.
   }
Child window:
//define the delegate
    public delegate void ChangeTextHandler();
    /// <summary>
    /// Interactive logic of FuncSetting.xaml
    /// </summary>
    public partial class WinFuncSetting : Window
    {
        public event ChangeTextHandler ChangeTextEvent;
        public WinFuncSetting()
        {
            InitializeComponent();
        }
         //Window close event You can trigger the event after any operation you need, I wrote it here in the window close
    private void Window_Closed(object sender, EventArgs e)
    {
StrikeEvent();
    }
    //Trigger an event to change the value of MainWindow
    private void StrikeEvent()
    {
        if (ChangeTextEvent != null)
        {
            ChangeTextEvent();
        }
    }
}


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325725054&siteId=291194637