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. Databinding in UserControl [modified]

Databinding in UserControl [modified]

Scheduled Pinned Locked Moved WPF
wpfhelpwcf
4 Posts 2 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.
  • M Offline
    M Offline
    mikla521
    wrote on last edited by
    #1

    I'm stuck (as usual). A have a user control with 6 textboxes. But to make it easier, I'm trying to break down the problem a bit and lets say there is one textbox. USERCONTROL1.XAML:CS

    public partial class AttenuationBox : UserControl
    {
    private String justAtest;
    public String ATest { get { return justATest; } set { ...

    public String LowChRx
    {
        get { return tbLowChRX.Text; }
        set { tbLowChRX.Text = value; }
    }
    

    ...
    }

    USERCONTROL1.XAML

    <textbox name="tbLowChRX" text="{Binding Path=ATest}"></textbox>

    Now I want tbLowChRX to be bound to justAtest. But just can't get it to work. Must be something I have missed in Source or Path or...

    modified on Sunday, April 19, 2009 12:49 PM

    M 1 Reply Last reply
    0
    • M mikla521

      I'm stuck (as usual). A have a user control with 6 textboxes. But to make it easier, I'm trying to break down the problem a bit and lets say there is one textbox. USERCONTROL1.XAML:CS

      public partial class AttenuationBox : UserControl
      {
      private String justAtest;
      public String ATest { get { return justATest; } set { ...

      public String LowChRx
      {
          get { return tbLowChRX.Text; }
          set { tbLowChRX.Text = value; }
      }
      

      ...
      }

      USERCONTROL1.XAML

      <textbox name="tbLowChRX" text="{Binding Path=ATest}"></textbox>

      Now I want tbLowChRX to be bound to justAtest. But just can't get it to work. Must be something I have missed in Source or Path or...

      modified on Sunday, April 19, 2009 12:49 PM

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      You will need to make sure the source is right on the binding. Here's a simple example of one way to do it: WPF: Binding to Properties in your UserControl or Window[^] I'm not sure why you'd want to bind directly to the field, nor do I think you can, but you should be able to bind to the ATest property. Of course, for change notifications when the property is updated, you may want to make that a dependency property. Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      M 1 Reply Last reply
      0
      • M Mark Salsbery

        You will need to make sure the source is right on the binding. Here's a simple example of one way to do it: WPF: Binding to Properties in your UserControl or Window[^] I'm not sure why you'd want to bind directly to the field, nor do I think you can, but you should be able to bind to the ATest property. Of course, for change notifications when the property is updated, you may want to make that a dependency property. Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        M Offline
        M Offline
        mikla521
        wrote on last edited by
        #3

        Oh, my fault, the intention was to bind to the property :)

        M 1 Reply Last reply
        0
        • M mikla521

          Oh, my fault, the intention was to bind to the property :)

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          Then that example at the link works... :)

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          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