开发者

Inject view into a container MVVM WPF

This has been giving me pain for some time.

I know P开发者_JAVA百科rism injects views into regions, however is there a way of doing a similar sort of thing with Cinch, on a view first basis? For example I have a container (effectively a region) which can contain any view at runtime - I don't particularly want to set the view explicitly in XAML as this will load it up, and it's a bit messy. Is there a container that I can use for this? And how would I go about it? (doesn't have to be Cinch specific..)

thanks.


To answer my own question I've found that Prism v4 has provided a useful solution - a RegionExtension called RequestNavigate.

I have used RequestNavigate for opening a new window (check out StockTrader RI) however this seems extremely cumbersome, if following the proper MVVM methodology. Instead I've decided to use the ChildWindow class in the WPF Extended Toolkit, where you can purely bind to the 'WindowState' (open/closed) property, and specify everything else in XAML.

I've also used RequestNavigate for injecting views into Regions - I'm now using MEF (at the time I was using Unity). I find the approach a lot more flexible, if slightly 'magic' regarding debugging.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜