// Constructor public MainPage() { InitializeComponent(); DataContext = new SampleModel { UserName = "******" }; }
private void Button_Click(object sender, RoutedEventArgs e) { SampleModel model = (SampleModel)DataContext; MessageBox.Show("You entered : " + model.UserName); }