Hide checkboxes in GridViewCheckBoxColumn

2 posts, 0 answers
  1. David Brubacher
    David Brubacher avatar
    29 posts
    Member since:
    Mar 2010

    Posted 06 Aug 2010 Link to this post

    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?
  2. David Brubacher
    David Brubacher avatar
    29 posts
    Member since:
    Mar 2010

    Posted 09 Aug 2010 Link to this post

    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
  3. DevCraft banner
Back to Top