通过按钮进行 WPF 导航
问题:有没有办法让按钮的行为类似于用户控件内的超链接?
我已经搜索了几天,但没有找到任何人解决了这个问题。如何使用按钮在 WPF 应用程序中进行导航?具体来说,如何使用户控件内的按钮导航其主机框架?请记住,用户控件无法直接访问主机框架。很简单:
this.NavigationService.Navigate(new Uri(this.addressTextBox.Text));
行不通。我正在使用用户控件。如果您仅使用页面,这就是您正在寻找的答案,如果您使用用户控件,请查看下面的我的答案。
Question: Is there a way to make a button behave like a hyperlink inside of a user control?
I've been searching around for a few days now and haven't found anyone who has addressed this. How do you use a button to navigate in a WPF application? Specifically how do you make a button inside of a user control navigate it's host frame? Bare in mind that User controls do not have direct access to the host frame. so simply:
this.NavigationService.Navigate(new Uri(this.addressTextBox.Text));
won't work. I'm using user controls. If you are using only pages, this is the answer you are looking for, if you are using UserControls, look at my answer below.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我觉得自己回答自己的问题就像个傻瓜,但我终于想通了!
我在这里找到了这个函数( http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/f8b02888-7e1f-42f4-83e5-448f2af3d207)将允许在用户控件内使用NavigationService。
~N
I feel like a goof ball for answering my own question, but i figured it out at long last!
This function i found here (http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/f8b02888-7e1f-42f4-83e5-448f2af3d207) will allow for the use of NavigationService inside of a user control.
~N
使用 NavigationService..::.Navigate 方法:
Use the NavigationService..::.Navigate Method: