c# - navigation in not working when [PartCreationPolicy(CreationPolicy.Shared)] in prism -


in prism application want make single shared instance of view. when try navigate first time works fine, when try second time it's not working. if change partcreationpolicy shared nonshared works it's give me new instance. there options way this?

[export(viewnames.appview)] [partcreationpolicy(creationpolicy.shared)]  public partial class appmain : usercontrol {     public appmain()     {         initializecomponent();     } } 

you might want play around prism's keepalive value view. value determines whether view should removed region when navigate away it. have 2 ways of doing this:

  1. using regionmemberlifetime attribute

    [regionmemberlifetime(keepalive = false)] [export(viewnames.appview)] [partcreationpolicy(creationpolicy.shared)]  public partial class appmain : usercontrol {     public appmain()     {         initializecomponent();     } } 
  2. implementing iregionmemberlifetime interface

    [export(viewnames.appview)] [partcreationpolicy(creationpolicy.shared)]  public partial class appmain : usercontrol, iregionmemberlifetime {     public appmain()     {         initializecomponent();     }      public bool keepalive     {         { return false; }     } } 

you can read more keepalive property here.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -