prism - Can't get same instance by using RegisterInstance -


i want register shellmodel container, can resolve in viewmodel whcich in module, can change window style in viewmodel. can't same instance of shellmodel in viewmodel, return new instance of shellmodel. write simple test below, i'm confused that.

public shell()     {         initializecomponent();         var shellmodel = new shellmodel();         iunitycontainer container = new unitycontainer();         container.registerinstance<shellmodel>(shellmodel);         console.writeline(container.resolve<shellmodel>().gethashcode());//41837403         console.writeline(container.resolve<shellmodel>().gethashcode());//41837403         iunitycontainer newcontainer = new unitycontainer();         console.writeline(newcontainer.resolve<shellmodel>().gethashcode());//3634967         console.writeline(newcontainer.resolve<shellmodel>().gethashcode());//29355815     } 

you're using 2 containers, , haven't registered instance in second container, unity returning new instance of shell(view?)model.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -