Recommended strategies for custom View location

Topics: Conventions, Extensibility
Dec 18, 2014 at 2:22 PM
Edited Dec 18, 2014 at 2:24 PM

I've got a ViewModel that is somewhat customized and which breaks the conventional mold locating Views.

In the views, I work through a couple of data templates and a data template selector in order to connect the dots, but this is outside the built-in CM view locator conventions.

That I've been able to determine, I can apparently implement IViewAware on my ViewModel to handle this concern. Magically the view appears, and apparently all I needed to do was "implement" the GetView method. Effectively I am returning null as the corresponding AttachView never seems to be called.

I've checked, and the connection does seem to be legit, but for the fact I've got an AttachView hanging out there without an implementation: i.e. throws NotImplementedException. 'Legit', that is to say communication to/from the ViewModel does happen.

So, with that background in mind, how is it that I am actually telling the locator which view(s) to use through IViewAware? Are there any examples of this sort of thing, i.e. customizing the view location and/or with data templates?

Here I am also wondering whether I need to implement a custom ViewLocator handler during my module bootstrap sequence.

Thank you...
Dec 18, 2014 at 4:41 PM
Turns out this was a Module source control snafu. I reverted the module, where I was replacing the view model resolution strategies, and now AttachView is fact happening first. It is happening for a default TextBlock, which seems odd, so likely I need to intervene during the view location strategy after all for certain types of view models.