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:
using
regionmemberlifetime
attribute[regionmemberlifetime(keepalive = false)] [export(viewnames.appview)] [partcreationpolicy(creationpolicy.shared)] public partial class appmain : usercontrol { public appmain() { initializecomponent(); } }
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
Post a Comment