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

Hide checkboxes in GridViewCheckBoxColumn

1 Answer 230 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David Brubacher
Top achievements
Rank 1
David Brubacher asked on 06 Aug 2010, 02:21 PM
I have a grid that has a data column and three checkbox columns. I am binding text in the data column and checked and enabled states in the check box columns. All is good, including single click checking using a custom behaviour.

Now I also want to bind the visible state of the checkbox on a record by record basis and can't get it to work. I've tried a datatemplate attached to the column definition with Visibility bound to the underlying object but the binding is ignored.

Does anyone have suggestions?

1 Answer, 1 is accepted

Sort by
0
David Brubacher
Top achievements
Rank 1
answered on 09 Aug 2010, 03:32 PM
I've solved this on my own by using a GridViewDataColumn and a data template as below
<grid:GridViewDataColumn Header="SRB1" IsGroupable="False" ShowDistinctFilters="False"
                        CellStyle="{StaticResource ControlCellStyle}" Width="45" HeaderTextAlignment="Center" 
                         IsFilterable="False" IsReorderable="False" IsResizable="False" IsSortable="False">
     <grid:GridViewDataColumn.CellTemplate>
          <DataTemplate>
              <CheckBox IsChecked="{Binding Srb1IsSelected, Mode=TwoWay}" HorizontalAlignment="Center"
                        VerticalAlignment="Center" Visibility="{Binding Srb1CanSelect}" IsThreeState="False"
                        IsEnabled="{Binding IsEnabled}" Controls:StyleManager.Theme="Windows7"
                        Command="{Binding EmissionClickCommand}" CommandParameter="SRB1"/>
          </DataTemplate>
     </grid:GridViewDataColumn.CellTemplate>
</grid:GridViewDataColumn>

I've also been able to drop the custom behaviour and still get single click changes to my check boxes
Tags
GridView
Asked by
David Brubacher
Top achievements
Rank 1
Answers by
David Brubacher
Top achievements
Rank 1
Share this question
or