getting and setting textbox.txt value in XAML from C# in Winform
-
Hi all, I am new to the WPF arena and am trying to get started. I have created a simple winform containing a treeview and an elementhost containing my XAML. The XAML contains a textbox. When I select a node in the treeview I want to pass the node name to the textbox. Everything is running fine but I do not know how to reference the controls within an XAML from the hosting winform. Any ideas, pointers, references I can look at?
-
Hi all, I am new to the WPF arena and am trying to get started. I have created a simple winform containing a treeview and an elementhost containing my XAML. The XAML contains a textbox. When I select a node in the treeview I want to pass the node name to the textbox. Everything is running fine but I do not know how to reference the controls within an XAML from the hosting winform. Any ideas, pointers, references I can look at?
Use this code: Text="{Binding ElementName=treeViewControlID, Path=SelectedNode.Text}" I am not sure "SelectedNode.Text" is available but it may be kind of property. If it is not workable then post here.
Parwej Ahamad ahamad.parwej@gmail.com
-
Hi all, I am new to the WPF arena and am trying to get started. I have created a simple winform containing a treeview and an elementhost containing my XAML. The XAML contains a textbox. When I select a node in the treeview I want to pass the node name to the textbox. Everything is running fine but I do not know how to reference the controls within an XAML from the hosting winform. Any ideas, pointers, references I can look at?
You can samply convert the child control to TextBox. Try this: private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { System.Windows.Controls.TextBox tb = (System.Windows.Controls.TextBox)(elementHost1.Child); tb.Text = e.Node.Name; }