Refactoring for shortening MainWindow.xaml.cs