I am adding the user controls during runtime based on a query of a database of XML data. So, the number of user controls is different.
Also, given the type of XML received, I cannot bind the user control to the list created from the XML data because there will instances where I will pull different fields based on whether this is a new client versus an existing client. For an existing client, there are only 8 fields. A new client needs 40 or 50 fields.
I am creating one of two user control based on new client versus the existing client.
I believe this is what is needed on the user control.
Here is the code snippet.
public event RoutedEventHandler btnAddClient_Click;
private void OnButtonClick(object sender, RoutedEventArgs e)
{
if(btnAddClient_Click !=null)
{
btnAddClient_Click(this, new RoutedEventArgs());
}
}
public ucNewClient()
{
InitializeComponent();
}
I need to know how to set the click event on the dynamically created user control and also the main form.
Any help would be greatly appreciated.
I have done multiple research and did not find help. What I found were user controls with a click event. However, the user control was not dynamically/during runtime.
I expect to perform an action of adding or updating a client to a list to perform tasks later in the project.