Below is some startup code to instantiate a ResourceManager for a WPF application. If I wanted this made available via xaml, would I put it in a resource dictionary? Use ObjectProvider? Something else?
Is there a reason to prefer one method of object instantiation over another in a WPF app?
Cheers,
Berryl
var asm = Assembly.Load("SampleApp.Common");
var resourceMan = new ResourceManager("SampleApp.Common.Resources.SupportedCultures", asm);
DataContext = new MainWindowVm(resourceMan);
In my opinion the static class is the best solution if you don’t need to replace dictionary during application lifetime:
XAML usage:
If there is multi-threaded environment,
_Managershould be assigned usingInterlocked.CompareExchangefor instance.