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

Binding GridViewDataColumn IsReadOnly to my MVVM does work?

1 Answer 141 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rob Ainscough
Top achievements
Rank 1
Rob Ainscough asked on 02 Feb 2018, 02:00 AM

I'm trying to dynamically enabled disable columns based on MVVM properties, but so far it's not working:

<telerik:GridViewDataColumn Header="Auto Close" Width="80" CellStyle="{StaticResource TelerikCellStyle}" DataMemberBinding="{Binding SiteAutoCloseDay}" IsSortable="False" IsReadOnly="{Binding AutoCloseDayEnableNot}">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <CheckBox IsChecked="{Binding SiteAutoCloseDay, Mode=TwoWay}" Tag="{Binding}" IsEnabled="{Binding AutoCloseDayEnable}">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <ei:CallMethodAction TargetObject="{Binding Path=DataContext, RelativeSource={RelativeSource AncestorType=UserControl}}" MethodName="SiteAutoCloseDaySelected" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </CheckBox>
        </DataTemplate>
     </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

 

Any suggestions?

Cheers, Rob.

1 Answer, 1 is accepted

Sort by
0
Rob Ainscough
Top achievements
Rank 1
answered on 02 Feb 2018, 05:03 PM

Ooops, I see the header to my question should read "does NOT work" ...

Anyway I solved my problem ... it was the binding path on the CheckBox in the CellTemplate ... this worked:

<CheckBox IsChecked="{Binding SiteAutoCloseDay, Mode=TwoWay}" Tag="{Binding}" IsEnabled="{Binding Path=DataContext.AutoCloseDayEnable, RelativeSource={RelativeSource AncestorType=UserControl}}">
Tags
GridView
Asked by
Rob Ainscough
Top achievements
Rank 1
Answers by
Rob Ainscough
Top achievements
Rank 1
Share this question
or