The Cookies Dog
The Cookies Dog

Reputation: 1940

WPF - Not working IsReadOnly in DataGrid with custom CheckBox style

I currently have a custom CheckBox style which I use in a DataGrid. However, when I specify the IsReadOnly="true" property in a DataGridCheckBoxColumn, this is no longer working (can I still click and change the value of the CheckBox). I also used Expression Blend to extract a copy of the original WPF style, and this one has the same problem. Only the original CheckBox style seems to be working, which I don't want.

I currently manage to solve it by creating a new style based on my normal one with the IsHitTestVisible and Focusable properties on false, but I want the IsReadOnly property from the DataGridCheckBoxColumn to work without this workaround.

How can I achieve this result?

Upvotes: 5

Views: 1428

Answers (2)

cheny
cheny

Reputation: 2735

There is an "IsEnabled" on CheckBox (should be on all other controls, I think) can do the job.

Upvotes: 0

stukselbax
stukselbax

Reputation: 5935

May be it is your case: try to set somewhere in the style this xaml:

IsReadOnly="{TemplateBinding}"

or

IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}"

Hope this help.

Upvotes: 0

Related Questions