wpf - How to make a styled DataGridCheckBoxColumn to respect DataGrid.IsReadonly? -


i have datagrid.isreadonly bound property changes based on condition. datagrid contains datagridcheckbox column had style in order center vertically in cell.

however, after applying style check box column not respect parent's isreadonly value. is, regardless of value checkbox can clicked on , changed. i've seen quite number of posts dealing similar situations not find reliable solution.

could please let me know how style checkbox column respects parent griddata's isreadonly? theory behind appreciated.

this how apply style:

<style x:key="centerstylecb" targettype="{x:type checkbox}">       <setter property="horizontalalignment" value="center" />       <setter property="verticalalignment" value="center" /> </style>  <datagridcheckboxcolumn ...  elementstyle="{staticresource centerstylecb}" /> 

add following code style:

<style.triggers>     <datatrigger binding="{binding path=column.isreadonly, relativesource={relativesource mode=findancestor, ancestortype={x:type datagridcell}}}" value="true">         <setter property="ishittestvisible" value="false" />     </datatrigger> </style.triggers> 

if datagrid readonly, suggest skip trigger , use setter directly.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -