I am discovering my views via MEF and Prism. However the constructor imports things which I do not want to load until after the full bootstrap has completed.
Rather than MEF go and instantiate all these objects for me at bootstrap time, I just want to register a View with MEF and a particular region, however only to construct and load it when I navigate to it for the first time.
Is this possible?
[Export("LegacyEntry")]
[ViewExport]
[PartCreationPolicy(CreationPolicy.Shared)]
public partial class LegacyEntry
{
public IEntryViewModel ViewModel
{
set => DataContext = value;
}
You would need to add Lazy<T>
when importing the module. Something like this:
[Import]
Lazy<LegacyEntry> LegacyEntry { get; set; }
or multiple
[ImportMany]
IEnumerable<Lazy<LegacyEntry>> LegacyEnties { get; set; }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.