1. Application in C# winform
2. Wpf element hosted in usercontrol
3. I want to set label on parent form on which wpf element is hosted.
4. I tried through constructor but is not possible yet.
5. I also made properties for this label and accessed in wpf code but not possible
Please anyone suggest me proper solution
Loading
Pravin ShuklaPosted Dec 19, 2013, 3:47 AM
Please use the below code snippet
private void elementHost1_ChildChanged(object sender, System.Windows.Forms.Integration.ChildChangedEventArgs e)
{
if (this.Parent == null || this.Parent.GetType() != typeof(Form1))
return;
var frm = this.ParentForm as Form1;
var label = frm.Controls["label1"] as Label;
var abc=elementHost1.Child;
if (elementHost1.Child.GetType() == typeof(WpfApplication1.UserControl1))
{
label.Text = "User Control 1";
}
else
label.Text = "User Control 2";
}
Here Form1 is parent Form and code is written in source file of User control where ElementHost is available.
Thanks
Pravin