Friday, 15 August 2014

xaml - WPF RadioButtonList Set both IsEnabled and IsChecked property from a collection -



xaml - WPF RadioButtonList Set both IsEnabled and IsChecked property from a collection -

i have re-styled listbox create radiobuttonlist link

my requirement : have select single item listbox @ time(ie single selection mode). have disable/enable listboxitem based on property bind collection. have set

ischecked="{templatebinding isselected}"

and bound isenabled property collection.

isenabled="{binding isenabled}"

and result follows:

you can see of records in disabled state, still selectable.if remove ischecked property, works expected. need both isenabled & isselected functionlaity. create multivalue converter isenabled property , based on values have bind corresponding value property. can't select disabled item list visually. when select disabled item, loss selection. please check image : .

and in code behind ischecked property set first record. want restrict selection. how can that? there settings in xaml help requirements? please advice...

thanks in advance....

it sounds you're binding isenabled property of radiobutton instead of listboxitem. disable radiobutton, not listboxitem, why can still selected.

you should able bind isenabled property of listboxitem, , work way want. 

based on link posted going style you're using, in itemcontainerstyle section of radiobuttonlist style:

<style targettype="{x:type listboxitem}" > <!-- here --> <setter property="isenabled" value="{binding isenabled}" /> <setter property="margin" value="5" /> <setter property="template"> <setter.value> <controltemplate targettype="{x:type listboxitem}"> <border borderthickness="0" background="transparent"> <radiobutton focusable="false" ishittestvisible="false" ischecked="{templatebinding isselected}"> <contentpresenter /> </radiobutton> </border> </controltemplate> </setter.value> </setter> </style>

wpf xaml wpf-controls isenabled

No comments:

Post a Comment