如何用RadCombobox填充RadGridView单元格

时间:2014-11-28 11:53:19

标签: telerik radgridview radcombobox

我有几列RadGridView。在一栏中,我有CellTemplate和CellEditTemplate。我想用我的组合框填充单元格,但无论将单元格填充设置为0还是将VerticalAligment设置为Stretch,它仍然有一个行高,顶部和底部有边距。有人有任何消化吗?

   <Style x:Name="BookCellStyle" TargetType="telerik:GridViewCell">
        <Setter Property="Padding" Value="0"/>
   </Style>  

                  <telerik:GridViewDataColumn  Width="*" 
                                                    MinWidth="200" 
                                                    TextAlignment="Center" 
                                                    IsReadOnly="False"
                                                    CellStyle="{StaticResource BookCellStyle}"
                                                    DataMemberBinding="{Binding BookId, Mode=TwoWay, NotifyOnValidationError=True}">

                            <telerik:GridViewDataColumn.CellTemplate>
                                <DataTemplate DataType="models:BookObject">

                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="15"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <TextBlock Grid.Column="0" Text="{Binding Path=BookNumber}" Margin="4,4,0,4"/>
                                        <TextBlock Grid.Column="1" Text="-" HorizontalAlignment="Center" Margin="0,4"/>
                                        <TextBlock Grid.Column="2" Text="{Binding Path=BookName}" TextWrapping="Wrap" MaxWidth="360" Margin="0,4,4,4"/>
                                    </Grid>
                                </DataTemplate>
                            </telerik:GridViewDataColumn.CellTemplate>

                            <telerik:GridViewDataColumn.CellEditTemplate>
                                <DataTemplate DataType="models:BookObject">
                                    <telerik:RadComboBox
                                                         ItemsSource="{Binding Path=Books}" 
                                                         SelectedValuePath="Guid"
                                                         SelectedValue="{Binding Path=BookId, Mode=TwoWay, NotifyOnValidationError=True}">

                                        <telerik:RadComboBox.ItemTemplate>
                                            <DataTemplate>
                                                    <Grid>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="15"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                    </Grid.ColumnDefinitions>
                                                    <TextBlock Grid.Column="0" Text="{Binding Path=BookNumber}" Margin="0,4"/>
                                                    <TextBlock Grid.Column="1" Text="-" HorizontalAlignment="Center" Margin="0,4"/>
                                                    <TextBlock Grid.Column="2" Text="{Binding Path=BookName}" TextWrapping="Wrap" MaxWidth="360" Margin="0,4"/>
                                                </Grid>
                                            </DataTemplate>
                                        </telerik:RadComboBox.ItemTemplate>
                                    </telerik:RadComboBox>
                                </DataTemplate>
                            </telerik:GridViewDataColumn.CellEditTemplate>
                         </telerik:GridViewDataColumn>

0 个答案:

没有答案