Skip to content

Instantly share code, notes, and snippets.

@sourcechord
Created September 28, 2015 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sourcechord/f90597e9eb6f9116b255 to your computer and use it in GitHub Desktop.
Save sourcechord/f90597e9eb6f9116b255 to your computer and use it in GitHub Desktop.
UWPでx:Bind使ってViewModelとバインドするためのPageクラスのスニペット
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
// DataContext変更時にViewModelプロパティの値が変わるように
// イベントハンドラの設定
this.DataContextChanged += (s, e) =>
{
ViewModel = this.DataContext as MainPageViewModel;
};
}
public MainPageViewModel ViewModel { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment