I create a WPF application using Prism and MEF. In one module, I have a Customer list. To edit customers data, I have one View "EditCustomer.xaml".
A user can edit many customers, so he can open many different instances of EditCustomer.xaml.
Here's code of the ViewModel :
[Export(typeof(EditCustomerViewModel))]
[PartCreationPolicy(CreationPolicy.NonShared)]
public class EditCustomerViewModel : ViewModelBase
And the code behing of XAML :
[Export(typeof(EditCustomerView))]
[PartCreationPolicy(CreationPolicy.NonShared)]
public partial class EditCustomerView : RadPane
{
public EditCustomerView()
{
InitializeComponent();
}
[Import(typeof(EditCustomerView))]
public object ViewModel
{
get
{
return this.DataContext;
}
set
{
this.DataContext = value;
}
}
}
The "CreationPolicy.NonShared" property works perfectly, but when I want to bind the customers data, every views are binded with the last values. I only want to load and display the latest data in the new view instance.
How can it be possible? Maybe I forgot something ?
In advance, thanks for your help.
Regards.