Now on Page 1 をC#
WPF
使用してページをホストするウィンドウがあります。ページ 1 で項目をダブルクリックすると、新しいウィンドウ (ページ 2) が開き、項目を編集できます。アイテムが編集されると、 に保存されます。今私が抱えている問題は、Page2 が閉じられると更新されないことです。基本的に、変更を表示するには、ページから離れてページに戻る必要があります。Page2 から Page1 を更新して変更を表示する方法はありますか? これが私のコードですthis.WorkingFrame.Navigate(Page1);
listview
listview
datacontext
listview
public partial class Page1 : Page
{
public Page1()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
//initiates the method to load data into the list view
LoadLV();
}
//Loads data into the list view object
public void LoadLV()
{
auroraDataEntities = new AuroraDataEntities();
Data data = new Data();
ObjectQuery<Inventory> inventories = auroraDataEntities.Inventories;
//Returns only objects with a quantity greater than 0, so it won't show anything you are out of
var fillList = from q in inventories
where q.Qty > 0
select q;
ingListLV.ItemsSource = fillList.ToList();
}
//Method to open what I want to be the child window basically a popup Dialog box
private void Open_Page2(object sender, RoutedEventArgs e)
{
Page2 openPage2 = new Page2();
openPage2.Show();
}
}
//This is the code for Page 2
public partial class Page2 : Window
{
public Page2()
{
InitializeComponent();
//ADDED a reference to Page1 in the constructor
Page1 page1;
}
//Method when i click the close button on the page
private void Close_Button(object sender, RoutedEventArgs e)
{
//In here is the code that I want to use to refresh the listview on page 1
//ADDED the call to the public method LoadLV on page 1
page1.LoadLV()
}
}