I have a main window with combobox data. Within the window I have a frame with a page, I need to refresh the data in the combobox (I have a method to do this) How do I call the method from the page?
in my MainWindow
public void getCustomers()
{
cb_Name.ItemsSource = ve.Folders;
cb_Name.DisplayMemberPath = "Full_Name";
cb_Name.SelectedValuePath = "Folder_Id";
cb_Name.SelectedIndex = 0;
}
in my page
private void btn_insert_person_Click(object sender, RoutedEventArgs e)
{
}
Maybe now more clearly
Say you have a method like in your main window class:
public void RefreshComboBox();
When you're creating the new frame you can pass a "method pointer" to it.
Let's pretend you're currently initializing the frame like this:
var frame = new Frame();
You can change its constructor to this:
public Frame(Action refreshComboBox)
and initialize the frame like this:
var frame = new Frame(RefreshComboBox);
Save a reference to the "method pointer" in your Frame class and call it when needed.
More info about the Action delegate here: http://msdn.microsoft.com/en-us/library/system.action.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.