0

I have in my XAML a ComboBox that has a binding to a list of components in a view model. Whenever the users clicks an item in the combo box, I want a dialog to pop open for the user to enter a number, click OK, and then close the dialog, saving the number in the viewmodel.

This is the combo box:

<ComboBox ItemsSource="{Binding Components}"
                  DisplayMemberPath="ComponentName"
                  SelectedItem="{Binding SelectedComponent}"
                  Grid.Column="0"></ComboBox>

I am aware this is not possible with a MessageBox, so I am unsure how to accomplish this in WPF. I want to avoid any code behind if possible. I had a look at this tutorial, but I'm unsure how to make this work with a viewmodel. I am using the MVVM pattern in my WPF application.

Where would I place the code for my input box and how would I save a value entered in a property?

Leth
  • 1,033
  • 3
  • 15
  • 40
  • Handling dialogs in MVVM has been discussed in numerous posts. See my answer in [this post](https://stackoverflow.com/questions/454868/handling-dialogs-in-wpf-with-mvvm/40478361#40478361) for example, which provides a way of showing dialogs and communicating dialog results back to MVVM. – dotNET Dec 17 '17 at 11:55
  • Thanks, I'll look into it. – Leth Dec 17 '17 at 16:31

0 Answers0