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

[Solved] About the CheckBox in GridView

1 Answer 129 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.
Max xu
Top achievements
Rank 1
Max xu asked on 06 Jan 2010, 06:30 AM
Excuse me,please.
   There is a CheckBox in the Cell of the GridView. Like this:

<grid:GridViewDataColumn x:Name="CheckBoxToSelectDocument" Header="" Width="30" IsReadOnly="True">
         <grid:GridViewDataColumn.CellTemplate>
         <DataTemplate>
            <CheckBox IsChecked="{Binding CheckBox1}" VerticalAlignment="Top" />
         </DataTemplate>
      </grid:GridViewDataColumn.CellTemplate>
     </grid:GridViewDataColumn>

But the VerticalAlignment of the checkbox is still in the center of the GridViewCell.
How Can I make the VerticalAlignment to be Top ?

Thank you in advance !

1 Answer, 1 is accepted

Sort by
0
Accepted
Rossen Hristov
Telerik team
answered on 06 Jan 2010, 12:30 PM
Hi Max xu,

You should define the cell style for the column like this:

<telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}">
    <telerik:GridViewDataColumn.CellStyle>
        <Style TargetType="telerikGrid:GridViewCell">
            <Setter Property="VerticalContentAlignment" Value="Top"/>
        </Style>
    </telerik:GridViewDataColumn.CellStyle>
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <CheckBox IsChecked="True" Background="Green" VerticalAlignment="Top"/>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

Let me know if this does not help.

Sincerely yours,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Max xu
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or