I haven’t investigated this more in depth, but it seems to me that this is impossible:
this.Resources["viewModel"] = new ViewModel();
At least it doesn’t work for me (actually I got a NotImplementedException), but it could be app specific. Anyway, this workaround strangely made it work:
ViewModel vm = this.Resources["viewModel"] as ViewModel;
if (vm != null)
vm = new ViewModel();
I.e. creating a local object reference from the resource – casting it to the desired type – and afterwards instantiating a new object via the new reference.
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.