static void ToastCommand_ValueChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { DemoPage2 self = obj as DemoPage2; if (self.ToastCommandChanged != null) { self.ToastCommandChanged(self, new EventArgs()); } self.updateUI(); }
private static void onBoundDataContextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { // e.NewValue is your new DataContext // d is your UserControl DemoPage2ViewModel viewModel = (DemoPage2ViewModel)e.NewValue; DemoPage2 userControl = (DemoPage2)d; if (viewModel != null) { userControl.ToastCommand = new RelayCommand(viewModel.ToastCommandExecute, viewModel.ToastCommandCanExecute); } }