How to align checkbox to center in GridViewDataColumn

3 posts, 0 answers
  1. Marthayaputra
    Marthayaputra avatar
    4 posts
    Member since:
    Oct 2013

    Posted 02 Oct 2013 Link to this post

    Hello Experts,

    I have tried several ways to make the checkbox centered in GridViewDataColumn with no luck. Could anyone help me please? Below is my XAML code
    Check box section
    <telerik:GridViewDataColumn CellStyle="{StaticResource MyCheckBoxStyle}">
                           <telerik:GridViewDataColumn.CellTemplate>
                               <DataTemplate>
                                   <!--<CheckBox x:Name="chk"  Content="" Click="Chk_OnClick" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="65,0,0,0"  IsChecked="{Binding IsSelected, Mode=TwoWay}">-->
                                   <CheckBox x:Name="chk" Content="" Click="Chk_OnClick" IsChecked="{Binding IsSelected, Mode=TwoWay}">
                                   </CheckBox>
                               </DataTemplate>
                           </telerik:GridViewDataColumn.CellTemplate>
                           <telerik:GridViewDataColumn.Header>
                               <CheckBox x:Name="chkAll" IsChecked="{Binding HasAllShopsMarked, Mode=TwoWay}" Loaded="ChkAll_Shop" Checked="ChkAll_Shop" Unchecked="ChkAll_Shop"
                                                                 Content="{Binding ResourceSet[MODULE_SETTINGS_SHOP_AUD_BATCH_UPDATE_ASSIGN_LBL], Source={StaticResource localSvc}, FallbackValue=Assign}" 
                                                                 Width="Auto" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,0,0,0" />
                           </telerik:GridViewDataColumn.Header>
                       </telerik:GridViewDataColumn>

    MyCheckBoxStyle Section :
    <Style x:Key="MyCheckBoxStyle" TargetType="telerik:GridViewCell">
               <Setter Property="HorizontalContentAlignment" Value="Center"/>
           </Style>

    Thanks in advance.

    Regards,
    Putra
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 02 Oct 2013 Link to this post

    Hi,

    In case you redefine the CellTemplate, then you should take care of centering the element you have placed for it.
    For example you can center the CheckBox similar to:
    <telerik:GridViewDataColumn.CellTemplate>
      <DataTemplate>
        <CheckBox IsChecked="{Binding IsSelected}" HorizontalAlignment="Center" />
      </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>


    Regards,
    Didie
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Marthayaputra
    Marthayaputra avatar
    4 posts
    Member since:
    Oct 2013

    Posted 02 Oct 2013 Link to this post

    Hi Didie,
    Thanks for your reply. I tried your suggestion but the result was still the same.
    It's still align on the left.

    Regards
Back to Top