简体   繁体   English

丢弃 WPF 页面以显示具有不同数据的该页面的新版本的最佳方法是什么?

[英]What is the best way to discard of a WPF page in order to display a new version of that page with different data?

In my program, navigation is structured along a path going Project->Board->Issue, then you are able to navigate back up to choose a different board.在我的程序中,导航是沿着 Project->Board->Issue 的路径构建的,然后您可以向上导航以选择不同的板。 It displays the issues in a list which can be picked from.它在可以从中挑选的列表中显示问题。 The trouble is that if you navigate to a different board, then choose a different issue from the ones displayed there, it still displays the first issue you selected.麻烦的是,如果您导航到不同的板,然后从那里显示的问题中选择不同的问题,它仍然会显示您选择的第一个问题。

I think the best solution is to dispose of the issue detail page when I navigate back, but I am unsure of how to do this.我认为最好的解决方案是在我返回时处理问题详细信息页面,但我不确定如何执行此操作。

Navigation from Board to Issues从董事会导航到问题

private void BtnSelect_Click(object sender, RoutedEventArgs e)
{
    var loginWindow = Window.GetWindow(this) as MainWindow;
    if (selectedBoard != null)
    {
        PageIssueSelect p = null;
        p = new PageIssueSelect(project, selectedBoard);
        loginWindow.Navigate(p);
    }
}

Navigation from Issue list back to Board:从问题列表导航回董事会:

private void BtnBack_Click(object sender, RoutedEventArgs e)
{
    items.Clear();
    lbxIssues.ItemsSource = null;
    project = null;
    var mainWindow = Window.GetWindow(this) as MainWindow;
    mainWindow.pageHolder.GoBack();
}

Navigation from Issue list to one issue:从问题列表导航到一个问题:

private void LbxIssues_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
    ListBox box = (ListBox)sender;
    var loginWindow = Window.GetWindow(this) as MainWindow;
    Issue issue = project.Issues[box.SelectedIndex];
    pageIssueDetail p = null;
    p = new pageIssueDetail(issue, project.name);
    loginWindow.Navigate(p);
}

Navigation from one issue back to the issue list从一个问题导航回到问题列表

{
    issue = null;
    var loginWindow = Window.GetWindow(this) as MainWindow;
    loginWindow.pageHolder.GoBack();
}

As far as I can tell, there should be no reason for the same issue to always be displayed, as each time it navigates forward it is creating a new page with a new issue selected.据我所知,没有理由总是显示相同的问题,因为每次向前导航时,它都会创建一个选择新问题的新页面。

Some of the unnecessary code lines in these are from me trying to create some kind of solution to the matter.其中一些不必要的代码行来自我试图为这个问题创建某种解决方案。

The issue laid in the data being fetched, not the pages.问题在于正在获取的数据,而不是页面。 I was using我正在使用

item = wholeList[index];

When I should have been using当我应该使用

item = filteredList[index];

Just answering in case this helps anyone else.只是回答以防万一这对其他人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将数据从用户控件发送到页面的最佳方式是什么? - What's the best way to send data from user control to the page? 在ASP.NET MVC中从页面到页面传递敏感数据的最佳方法是什么? - What is the best way to pass sensitive data from page to page in ASP.NET MVC? 检查页面上是否存在元素的最佳方法是什么? - What is the best way to check if element exist on page? 在ASP.net网页上显示交换邮件的最佳方法是什么? - What is the best way to display an exchange mail message on an ASP.net web page? 从目录在ListBox WPF或Silverlight中显示图像的最佳方法是什么 - What is the BEST Way to display images in a ListBox WPF or Silverlight FROM a directory 在WPF控件上显示“加载”指示符的最佳方法是什么 - What is the best way to display a 'loading' indicator on a WPF control 在WPF中将新页面居中 - Centering a new page in a wpf 在WPF中显示图像的最佳方式 - Best way to display image in WPF 对使用不同版本的签名程序集编写的泛型进行反序列化的最佳方法是什么? - What is the best way to deserialize generics written with a different version of a signed assembly? WPF-将数据从数据库绑定到复选框控件的最佳方法是什么 - WPF - what is the best way to bind data from a database to a checkbox control
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM