具有树视图选定事件的用户控件刷新了另一个用户控件不起作用
我对 WPF 编程比较陌生,似乎无法使其正常工作。在我看来,这是相当简单的事情,我想要开始工作,所以我没有尝试 MVVM 框架并决定保持简单。
我有一个带有报告路径的用户控件树视图。我有另一个带有报表查看器的用户控件。在树视图中选择报告路径应刷新报告查看器。
我可以从树视图用户控件“调用”该方法来刷新报表用户控件中的报表查看器,但没有任何反应。
我正在阅读其他帖子,有些帖子似乎建议向委托提供一个按钮事件,该委托将允许执行其他用户控件方法。我没有使用按钮事件,所以我有点困惑。
我想我可以做这样的事情:
private void treeViewMenu_Selected(object sender, RoutedEventArgs e)
{
//Get the selected item
....
//Call the method of another user control
ReportUserControl ruc = new ReportUserControl();
ruc.RefreshReport();
}
显然这不起作用......我知道这应该不会太困难,但我正处于大脑冻结的时刻,似乎无法让它发挥作用。
任何建议将不胜感激。 谢谢!
I'm relatively new to WPF programming and can't seem to get this working correctly. This is in my mind something rather simplistic that i would like to get working so I didn't try the MVVM framework and decided to keep it simple.
I have a usercontrol treeview with report paths. I have another usercontrol with a reportviewer. Selecting a report path in the treeview should refresh the reportviewer.
I can "call" the method from the treeview usercontrol for refreshing the reportviewer in the report usercontrol but nothing happens.
I was reading other posts and some seem to suggest a button event to a delegate that will allow the other usercontrol method to be executed. I'm not using a button event so I'm a bit puzzled.
I thought I could do something like this:
private void treeViewMenu_Selected(object sender, RoutedEventArgs e)
{
//Get the selected item
....
//Call the method of another user control
ReportUserControl ruc = new ReportUserControl();
ruc.RefreshReport();
}
Obviously that didn't work...I know that it shouldn't be too difficult but i am in a brain freeze moment and can't seem to get it working.
Any suggestions would be greatly appreciated.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论