[英]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.