Empty row above last row when inserting manually row in GridView

2 Answers 23 Views
GridView
cwider
Top achievements
Rank 1
Iron
cwider asked on 12 May 2021, 10:32 PM | edited on 12 May 2021, 10:38 PM

Hi to all,

Maybe someone can help me with my problem. Thank you all in advance for any suggestions.

When I programmatically add a row/item to the RadGridView I have always am empty row above the last row:

 

Here is my XAML code:

            <Border x:Name="m_borderOperands" BorderThickness="3" CornerRadius="5" >
                <telerik:RadGridView x:Name="m_dgOperands" Margin="1" Background="#FF2C2C2C" CanUserGroupColumns="False" 
                                     telerik:StyleManager.Theme="Expression_Dark" BorderThickness="0"
                                     SelectionMode="Extended" SelectionUnit="Mixed" CanUserSortColumns="False" 
                                     CanUserSelectColumns="True" ShowColumnFooters="False" ShowColumnHeaders="True" 
                                     IsFilteringAllowed="False" CanUserFreezeColumns="False" CanUserDeleteRows="False" 
                                     ClipboardPasteMode="Cells" ClipboardCopyMode="Cells" 
                                     ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                     ScrollViewer.VerticalScrollBarVisibility="Visible" 
                                     ShowGroupPanel="false" EditTriggers="TextInput" GroupRenderMode="Flat" 
                                     FontSize="14" MaxWidth="2560" MaxHeight="1600" ValidatesOnDataErrors="InEditMode" 
                                     EnableColumnGroupsVirtualization="True" EnableColumnVirtualization="True" 
                                     EnableRowVirtualization="True" CanUserInsertRows="False" EnableStickyGroupHeaders="False" 
                                     ColumnsSelectionButtonVisibility="Collapsed" ShowGroupFooters="True"
                                     FrozenColumnsSplitterVisibility="Collapsed" />
            </Border>

Here are my GridView styles:

    <UserControl.Resources>
        <Style TargetType="telerik:GridViewHeaderCell">
            <Setter Property="LayoutTransform">
                <Setter.Value>
                    <RotateTransform Angle="-90" />
                </Setter.Value>
            </Setter>
            <EventSetter Event="PreviewMouseUp" Handler="GridViewHeaderCell_PreviewMouseUp"/>
            <Setter Property="TextWrapping" Value="NoWrap"/>
            <Setter Property="Margin" Value="1,10,1,3"/>
        </Style>

        <Style TargetType="telerik:GridViewHeaderRow">
            <Setter Property="MinHeight" Value="10"/>
        </Style>
        <Style TargetType="telerik:GridViewFooterRow">
            <Setter Property="Background" Value="#FF303030"/>
        </Style>
        <Style TargetType="telerik:GridViewCell">
            <Style.Triggers>
                <Trigger Property="Value" Value="1">
                    <Setter Property="Background" Value="#4CFFFF00" />
                </Trigger>
                <Trigger Property="Value" Value="2">
                    <Setter Property="Background" Value="#4C32CD32" />
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style TargetType="telerik:CommonColumnHeader">
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="FontWeight" Value="Bold"></Setter>
            <Setter Property="Background" Value="#FF303030" />
        </Style>
        <DataTemplate x:Key="GridViewCellImageTextTemplate">
            <StackPanel Orientation="Horizontal">
                <Image Source="{Binding Image}" Margin="0,0,5,0" MaxHeight="16" MaxWidth="16" />
                <TextBlock Text="{Binding InfoText}"/>
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>

And here my c# code:
        private void AddStepToDataGrid(SelmoCreatorStepBase stepBase, int idxInsert)
        {
            if (idxInsert >= 0)
            {
                m_dgOperands.Items.Insert(idxInsert, stepBase);
            }
            else
            {
                m_dgOperands.Items.Add(stepBase);
            }
        }

I appreciate any help.

Best regards

Christoph

2 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 17 May 2021, 09:58 AM

Hello Christoph,

I've tested the code snippets, but I wasn't able to reproduce the issue. Can you check the attached project and let me know if I am missing anything?

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
cwider
Top achievements
Rank 1
Iron
answered on 18 May 2021, 07:26 PM

Hello Martin,

thank you for your answer.

I will check your provided project and I will give you a feedback.

Best regards,

Christoph Wider

Tags
GridView
Asked by
cwider
Top achievements
Rank 1
Iron
Answers by
Martin Ivanov
Telerik team
cwider
Top achievements
Rank 1
Iron
Share this question
or