具有树视图选定事件的用户控件刷新了另一个用户控件不起作用

发布于 2024-11-02 23:15:19 字数 632 浏览 0 评论 0原文

我对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文