I have been following this pattern. http://www.codeproject.com/Articles/36745/Showing-Dialogs-When-Using-the-MVVM-Pattern
However, in this example, in the PersonDialog.xaml.cs class, I'm not able to access this.DataContext. It's always null. Since I'm using DialogService to open a window(where I'm setting the DataContext there to ViewModel and also passing on the data to PersonDialogViewModel from MainWindowViewModel) I need that instance of ViewModel. I'll not be able to create another PersonDialogViewModel from View.
Please suggest as I need to access Data from the ViewModel in the code behind.
Here is the code.
//MainWindowViewModel.cs
PersonViewModel selectedPerson = persons.Single(p => p.IsSelected);
PersonDialogViewModel personDialogViewModel = new PersonDialogViewModel(selectedPerson.Person);
dialogService.ShowDialog<PersonDialog>(this, personDialogViewModel);
//In PersonDialogViewModel.cs
public PersonDialog()
{
InitializeComponent();
var obj = this.DataContext;//DataContext is always null.
}