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. .NET (Core and Framework)
  4. Xaml: Data Binding Two Controls To One Source

Xaml: Data Binding Two Controls To One Source

Scheduled Pinned Locked Moved .NET (Core and Framework)
wpfhelpcsharpwcfcom
2 Posts 2 Posters 1 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.
  • J Offline
    J Offline
    Jm6k
    wrote on last edited by
    #1

    Hello All, I'm running into a problem and I was wondering if anyone could help me out. I'm trying to data bind two combo boxes to one data table. I've got it to work, however when I change the selection of one combo box, the other one changes as well. I've seen a lot of documentation on how to solve this problem in the 2.0 framework, however, I've not seen any help on this topic so far. I would like it so that the changes between the combo boxes are independant of each other (i.e. combobox1 can select item 1, and combobox2 can select item 2) Here is my code... C#=================================================== ...In the my Page object's .xaml.cs file... DataTable table = new DataTable("table1"); DataColumn lName = new DataColumn("FullName", typeof(string)); table.Columns.Add(lName); //Add Column to Table //Create Row DataRow r1 = table.NewRow(); //Fill Data For Row r1["FullName"] = "smith, joe"; table.Rows.Add(r1); DataContext = table; //set the Page object's Data Context to the Data Table Xaml================================================== ===================================================== Thank you in advance for your time. Also, I didn't know if this was the right forum to post this, sorry if I was wrong! jm6k The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew

    P 1 Reply Last reply
    0
    • J Jm6k

      Hello All, I'm running into a problem and I was wondering if anyone could help me out. I'm trying to data bind two combo boxes to one data table. I've got it to work, however when I change the selection of one combo box, the other one changes as well. I've seen a lot of documentation on how to solve this problem in the 2.0 framework, however, I've not seen any help on this topic so far. I would like it so that the changes between the combo boxes are independant of each other (i.e. combobox1 can select item 1, and combobox2 can select item 2) Here is my code... C#=================================================== ...In the my Page object's .xaml.cs file... DataTable table = new DataTable("table1"); DataColumn lName = new DataColumn("FullName", typeof(string)); table.Columns.Add(lName); //Add Column to Table //Create Row DataRow r1 = table.NewRow(); //Fill Data For Row r1["FullName"] = "smith, joe"; table.Rows.Add(r1); DataContext = table; //set the Page object's Data Context to the Data Table Xaml================================================== ===================================================== Thank you in advance for your time. Also, I didn't know if this was the right forum to post this, sorry if I was wrong! jm6k The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew

      P Offline
      P Offline
      Phillip M Hoff
      wrote on last edited by
      #2

      I am by no means a WPF expert, but could it be because both of your controls have the IsSynchronizedWithCurrentItem set to True? You might also try asking the question on MSDN's WPF forum: WPF[^] -Phil

      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