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