Self recycle RowDetails

4 posts, 0 answers
  1. Arthur
    Arthur avatar
    7 posts
    Member since:
    May 2014

    Posted 27 May 2014 Link to this post

    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
  2. Arthur
    Arthur avatar
    7 posts
    Member since:
    May 2014

    Posted 27 May 2014 Link to this post

    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?
  3. Arthur
    Arthur avatar
    7 posts
    Member since:
    May 2014

    Posted 27 May 2014 Link to this post

    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.
  4. Yoan
    Admin
    Yoan avatar
    1213 posts

    Posted 29 May 2014 Link to this post

    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.
     
Back to Top