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

Self recycle RowDetails

3 Answers 67 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Arthur
Top achievements
Rank 1
Arthur asked on 27 May 2014, 08:34 AM
Hi,

I am just trying to improve scroll performance, when the RowDetailsVisibilityMode is set to "Visible", because it is slow for complex detail controls.
Now I am doing this:

<DataTemplate x:Key="DetailTemplate">
    <ContentControl/>
</DataTemplate>

In code behind:

List<TextBlock> notInUse = new List<TextBlock>();

public DataListEditor()
{
    InitializeComponent();

    for (int i = 0; i < 100; ++i)
    {
        TextBlock tb = new TextBlock();
        notInUse.Add(tb);
    }

    dataListGrid.LoadingRowDetails += dataListGrid_LoadingRowDetails;
    dataListGrid.UnloadingRowDetails += dataListGrid_UnloadingRowDetails;
}

void dataListGrid_UnloadingRowDetails(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e)
{
    ContentControl c = e.DetailsElement as ContentControl;

    TextBlock tb = c.Content as TextBlock;

    if (tb != null)
    {
        c.Content = null;
        notInUse.Add(tb);
    }
}

void dataListGrid_LoadingRowDetails(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e)
{
    ContentControl c = e.DetailsElement as ContentControl;

    if (c.Content == null)
    {
        Binding b = new Binding("Roles[0].DisplayName");
        b.Source = e.Row.DataContext;

        TextBlock tb = notInUse[0];
        notInUse.RemoveAt(0);

        tb.SetBinding(TextBlock.TextProperty, b);
        c.Content = tb;
    }
}

In other words: I try to recycle detail controls, so that there is no need to recreate them. This works fine, when I am only scrolling. But if I resize the window, the DetailsPresenter of a row seems not to be measured to its content, so the text block is there with the right height, but its visual ancestors have a wrong height and the textblock is not visible. Is there a workaround to solve this?

Thanks

3 Answers, 1 is accepted

Sort by
0
Arthur
Top achievements
Rank 1
answered on 27 May 2014, 09:37 AM
OK,

the problem can be reformulated: Forget the code behind. If the details DataTemplate contains a ContentControl for example with MinHeight = 20 the problem  still occurs, because not all row details are visible when the window is resized. Is this a bug?
0
Arthur
Top achievements
Rank 1
answered on 27 May 2014, 11:49 AM
I have opened a ticket. For those who stumble across the same problem. It seems that if GroupRenderMode is set to "Flat", details are not measured correctly when the GridView is resized. If I set the PART_DetailsPresenter Height via Snoop to the expected size, I can see what I expect.
0
Yoan
Telerik team
answered on 29 May 2014, 04:58 PM
Hi Arthur,

Actually, this issue is a known one. It is logged into our Feedback portal as a bug report. You can track its status: Visible RowDetails collapse when GroupRenderMode=Flat and maximize/minimize the window

Regards,
Yoan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Arthur
Top achievements
Rank 1
Answers by
Arthur
Top achievements
Rank 1
Yoan
Telerik team
Share this question
or