开发者

Simple way to call a method on the View (Code Behind)

I have a small issue I was hoping somebody could help me with. I have to call the NavigationService.RemoveBackEntry() on two of my views due to the way I have my first run wizard set up.

This method needs to be called on the view (in the codebehind) as far as I am aware and cannot be called in my view models.

I was wondering what would be the easiest, cleanest way to call a RemoveLastNavEntry() from the ViewModel if the method lives on the view.

Rob has said it is a feature he will build into the navigation service at some point but until then I need to implem开发者_如何转开发ent this as a minor hack.


While this truely is a task for the view, you can, if you really want to, call it from the ViewModel, as a static call.

(App.Current.RootVisual as PhoneApplicationFrame).RemoveBackEntry()

See PhoneApplicationFrame.RemoveBackEntry Method for documentation.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜