I have a small Dialog where i can set a value. The View of this Dialog has just one TextBox and two buttons. I am binding the textbox.Text to a property TbText in the ViewModel. Through a behavior i close the view from it’s viewmodel. The code to open this dialog looks like:
AddLineDialog dialog = new AddLineDialog();
bool? result = dialog.ShowDialog();
if(result.HasValue && result.Value)
{
//Here i need the Text from the closed dialog
}
...
After the Dialog is closed i need to access the value of the Property TbText. How can i achive this?
You can bind a ViewModel or any class to the Dialog’s Datacontext:
Then bind the textbox to a property from your class
After this you can read out your class