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. RadioButton in DataGrid - How does it update the bound property?

RadioButton in DataGrid - How does it update the bound property?

Scheduled Pinned Locked Moved WPF
questiondatabasewpfwcftutorial
1 Posts 1 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.
  • D Offline
    D Offline
    Duke Carey
    wrote on last edited by
    #1

    This is related to the question asked the other day (that didn't garner any responses). Entity Framework 5, database first Simple class

    class PhoneNumber
    {
        public int ID { get; set; }
        public int ContactID { get; set; }
        public string PhoneNbr { get; set; }
        public string NbrType { get; set; }
        public bool Preferred { get; set; }
    
        public virtual Contact Contact { get; set; }
    }
    

    In my view model the PhoneNumbers for a contact are retrieved into an

    ObservableCollection

    A person will have 0-M phones, though only one of them should be preferred. The view has a DataGrid that is bound to the collection of PhoneNumber. Initiatally I was using a DataGridCheckBoxColumn to show the Preferred Boolean property and I couldn't (still can't) figure out how to enforce a rule that says only one row can be checked. Somebody suggested I use a DataGridTemplateColumn with a RadioButton control instead, and use a group to enforce the rule. In a test project I did that like so:

    Visually this works fine - setting any one row to preferred clears the radio buttons for all other rows. However, the Preferred property appears to not update for any of the entities in the collection. Do I need to change the binding in some fashion?

    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