Sunday 15 March 2015

mvvm light - Avoiding Locator Bloat -


After a few years interval, just starting a new project with MVVM lighting, I was opening my first VM using ViewModelLocator And I think that for every new visual model we need to make a new asset. I'm just wondering how to avoid it because the app has some visual models (50+). I have worked to use the value converter, but then I loose intimate in the XML editor.

Examples of people whose solutions can be resolved are appreciated.

Note - There is a solution using a value converter, so I can pass the parameter to some IOC and get the VM, but then I get the open ingenence (welcomil gets a squiggle) .

  & lt; Window X: class = "My.MainWindow" DataContext = "{binding source = {static resource locator}, converter = {static resource locator}, converter parameter = 'afu'}" & gt; & Lt; Window.Resources & gt; & Lt; ResourceDictionary & gt; & Lt; ResourceDictionary.MergedDictionaries & gt; & Lt; Resource Source Source = "Skins / Menace. XML" /> & Lt; /ResourceDictionary.MergedDocs> & Lt; / ResourceDictionary & gt; & Lt; /Window.Resources> & Lt; Grid X: Name = "Layouts" & gt; & Lt; TextBlock FontSize = "36" fontweit = "bold" foreground = "purple" text = "{binding wellcome}" vertical element = "center" horizontal alignment = "center" textweeping = "wrap" /> & Lt; / Grid & gt; & Lt; / Window & gt; Update: Another method is better than using a converter, but is still suffering from welcomital skunk because the XAML editor does not know this type of address. I wonder what effect "blendability"? (I do not have good mixing.)  

thanks

For Intellisense, can you try more boilerplate on resources?

  /// & lt; Summary & gt; /// To include things classes /// & lt; / Summary & gt; /// & lt; Typename name = "t" & gt; User id & lt; / Typermum & gt; /// & lt; Typewritten name = "vaccine" & gt; Username & lt; / Typermum & gt; Public class MyDictionary & lt; T, TK & gt; : Dictionary & lt; T, TK & gt;   

Or what about using a shared resource dictionary to please intellisense?

Due to dependency injection is a good way to reduce redundancy locator code, it includes a general way of registration service or model providers.

If you want to create a new asset for each visual model, it can indicate a weakness in your actual model. When working with VMs, I usually find that they are unfavorable, this model contains all relevant data, and see the model is prepared as a subset of important properties for that scene.

This is not uncommon for a large project of 50+ visual models

No comments:

Post a Comment