I Have a bound Data grid view to the below Questions Class:
public class Questions()
{
public int QuestionId{get; set;}
public string Question {get; set;}
public List<Answers> AvailableAnswers {get; Set;}
public string SelectedAnswer {get; set;}
}
public class Answers()
{
public int AnswerId {get; set;}
public string Answer {get; set;}
public bool IsSelected {get; set;}
}
What I need is within my Datagrid to show the Available Answers as Radio buttons and when the user selects one of the radio buttons for the AnswerId to be set as the SelectedAnswer property in the Questions Class.
Can anyone help as i have been going round in circles trying to do this
There are a few ways you can do this if you are using MVVM within your view-model you can create a public property such as
And then in the UI binding similar to
Assuming you have the data context set at the grid or main view to the view model.
You could then bind this property to the UI and when checked it could then invoke a different action or method for another element. It just depends upon how you implement this.
If you are not using mvvm and you want to handle this in the ui you can use elementName binding. Here you basically bind property of one element on the value of another (Example check a checkbox and have a value appear in the UI) Here is a link from MSDN on element name binding
MSDN Link Here