Created
November 21, 2013 14:47
-
-
Save masaru-b-cl/7582834 to your computer and use it in GitHub Desktop.
WeakEventパターンで実装
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Windows; | |
| namespace WpfApplication1 | |
| { | |
| /// <summary> | |
| /// MainWindow.xaml の相互作用ロジック | |
| /// </summary> | |
| public partial class MainWindow : Window | |
| { | |
| private readonly MainWindowViewModel vm; | |
| public MainWindow() | |
| { | |
| InitializeComponent(); | |
| vm = DataContext as MainWindowViewModel; | |
| WeakEventManager<MainWindowViewModel, EventArgs>.AddHandler(vm, "Hide", (sender, e) => this.Hide()); | |
| } | |
| private void Button_Click(object sender, RoutedEventArgs e) | |
| { | |
| vm.HideWindow(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment