private void TimingSwitch_Click(object sender, RoutedEventArgs e) { _parent = this.FindVisualParent <Panel>(); if (_parent != null) { _parent.Children.Remove(this); _timeSwitch = new TimeSwitchPlanControl(); _timeSwitch.ViewModel.ReturnAction += BackToCurrent; _parent.Children.Add(_timeSwitch); } }
private void BackToCurrent() { if (_timeSwitch != null) { _timeSwitch.ViewModel.ReturnAction -= BackToCurrent; } if (_parent != null) { _parent.Children.Remove(_timeSwitch); _parent.Children.Add(this); _timeSwitch = null; } }