Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. getting and setting textbox.txt value in XAML from C# in Winform

getting and setting textbox.txt value in XAML from C# in Winform

Scheduled Pinned Locked Moved WPF
csharpwpfhostingtutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Colin Bowdery
    wrote on last edited by
    #1

    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?

    P C 2 Replies Last reply
    0
    • C Colin Bowdery

      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?

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • C Colin Bowdery

        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?

        C Offline
        C Offline
        carlecomm
        wrote on last edited by
        #3

        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; }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups