S
S
Snape112018-10-11 20:27:52
WPF
Snape11, 2018-10-11 20:27:52

Wpf Mvvm How to get value from another form?

I need to call another form from a form and get the value of the key that was pressed on the new form. How to do it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sumor, 2018-10-11
@Snape11

You have one ViewModel, which you pass from one form to another (set, for example, in the DataContext). By pressing a key in the second form, save what you need in the passed ViewModel and automatically this information will become available in the first form.

void button_click(object sender, RoutedEventArgs e)
{
  var form = new Form2(){DataContext = DataContext};
  form.ShowDialog();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question