I have two columns of Radio Buttons => snipboard.io/Xy3IQr.jpg.
xaml
...
xaml.cs
//------------------------------
private void gRBuResearcher1_Click(object sender, RoutedEventArgs e)
{
gstCharacter1 = "Researcher";
}//gRBuResearcher1_Click
//------------------------------
//------------------------------
private void gRBuScientist1_Click(object sender, RoutedEventArgs e)
{
gstCharacter1 = "Scientist";
}//gRBuScientist1_Click
//------------------------------
//------------------------------
private void gRBuMedic1_Click(object sender, RoutedEventArgs e)
{
gstCharacter1 = "Medic";
}//gRBuMedic1_Click
//------------------------------
//------------------------------
private void gRBuDispatcher1_Click(object sender, RoutedEventArgs e)
{
gstCharacter1 = "Dispatcher";
}//gRBuDispatcher1_Click
//------------------------------
...
//------------------------------
private void gRBuResearcher2_Click(object sender, RoutedEventArgs e)
{
gstCharacter2 = "Researcher";
}//gRBuResearcher2_Click
//------------------------------
//------------------------------
private void gRBuScientist2_Click(object sender, RoutedEventArgs e)
{
gstCharacter2 = "Scientist";
}//gRBuScientist2_Click
//------------------------------
//------------------------------
private void gRBuMedic2_Click(object sender, RoutedEventArgs e)
{
gstCharacter2 = "Medic";
}//gRBuMedic2_Click
//------------------------------
//------------------------------
private void gRBuDispatcher2_Click(object sender, RoutedEventArgs e)
{
gstCharacter2 = "Dispatcher";
}//gRBuDispatcher2_Click
//------------------------------
If "Researcher" is selected in the 1st col, how do I block "Researcher" from being selected in the 2nd col?
Jayraj ChhayaPosted Dec 2, 2024, 6:03 AM
To block the second RadioButton when the first one is selected, you can handle the
Clickevent of the first RadioButton and set theIsEnabledproperty of the second RadioButton accordingly. Below is an example of how to implement this in your WPF application.First, ensure that your RadioButtons are defined in XAML as follows:
Then, in your code-behind, implement the following logic:
This approach ensures that when any RadioButton in the first column is selected, the corresponding RadioButton in the second column is disabled, preventing user selection. You can re-enable the second RadioButton based on your application's logic as needed.