Reputation: 1419
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
Upvotes: 0
Views: 153
Reputation: 3925
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
Upvotes: 2