This is a migrated thread and some comments may be shown as answers.

Conditional CheckBoxes in WPF RadGridView

3 Answers 182 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 26 May 2017, 08:45 PM

I'm trying to understand the best path forward to implement a column of CheckBoxes in a RadGridView. The CheckBoxes need to be conditionally visible (or hidden) per row-level business logic (a boolean value for each row, a different property from the one represented in the CheckBox).

While I have been able to implement this successfully using a DataTemplateSelector, which switches in either a CellTemplate containing the CheckBox, or an "empty" CellTemplate... I am still having a challenge with controlling the UI behavior. What happens is if a user clicks the empty cell, it goes into Edit Mode, as if accepting text; I don't want this to happen... it should remain empty and not allow any interaction. For the cell with the CheckBox, I can click inside and toggle the CheckBox on and off (checked/unchecked), which is great... but if a user clicks just outside the CheckBox but still inside the cell where the CheckBox resides, it too will enter Edit Mode, as if accepting text (and it hides the CheckBox). Again, I don't want this to happen.

What's the best path for allowing only a CheckBox inside such a column, and disallowing any UI elements other than the conditionally appearing CheckBoxes?

Thanks in advance for your help.

3 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 30 May 2017, 01:53 PM
Hello Barry,

A simple way to go around this undesired behavior would be to set the IsReadOnly property of the respective column to True.

Do let me know whether such an approach would work for you.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Barry
Top achievements
Rank 1
answered on 30 May 2017, 02:10 PM

I set the Column's IsReadOnly to True, and that does indeed work. I did not try that before, as that seemed counterintuitive...  why does that not also make the checkboxes read-only? 

 

0
Dilyan Traykov
Telerik team
answered on 31 May 2017, 02:13 PM
Hello Barry,

The column's IsReadOnly property does not affect the elements inside its CellTemplate as they are directly bound to the underlying values.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Barry
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Barry
Top achievements
Rank 1
Share this question
or