Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a Silverlight grid, which is having a Checkbox column, currently the user can select multiple rows. But the silverlight grid should allow only one checkbox to be selected(If another selected the other should deselect - like Radiobutton). So i will get the row data of grid from Checkbox checked.

, Can anybody suggest how to make the above requriement.

Many thanks....
Posted

Easiest way - run a loop through the checkbox datasource (assuming your binding is two way).
Check the one selected and remove the selection on the others.
 
Share this answer
 
C#
CheckBox previousCheckBox = null;
        private void chkPerson_Click(object sender, RoutedEventArgs e)
        {
            if(previousCheckBox!=null)
            {
                previousCheckBox.IsChecked = false;
            }

            CheckBox currentCheckBox = sender as CheckBox;
            previousCheckBox = currentCheckBox;
        }

        private void chkPerson_Unchecked(object sender, RoutedEventArgs e)
        {
            previousCheckBox = null;
        }
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900