I am totally new to WPF. I'm using DevExpress mvvm framework. I want to show a window from a viewmodel.
The code I am using is
public void NewEntity()
{
var factory = ViewModelSource.Factory((RemoteTable<AddressLocatorView> aRemoteTable) => new CreateEntityWizardViewModel(aRemoteTable));
CreateEntityWizardViewModel aVM = factory(fDataModule.DataAdapter.GetTable<AddressLocatorView>());
DialogService.ShowDialog(dialogCommands: null, title: "New Entity Wizard", viewModel: aVM);
}
This will open a form and set the viewmodel.
Though, in the form's constructor, I have
public CreateEntityWizard()
{
InitializeComponent();
}
Which, in turn, calls the public parameterless constructo of the EntityWizardViewModel. The EntityWizardViewModel is created twice, once by the factory method, and second by the InitializeComponent() which, I believe, does it by the means of the XAML :
DataContext="{dxmvvm:ViewModelSource Type={x:Type ViewModels:CreateEntityWizardViewModel}}"
What is the approach to pass a ViewModel to a form using the DialogService ?
Thank you