Width="*" for a GridViewDataColumn with Grouping causes freeze

7 posts, 1 answers
  1. Louis
    Louis avatar
    83 posts
    Member since:
    Aug 2013

    Posted 12 Mar 2014 Link to this post

    I've run into an issue where GridView will freeze when trying to auto-adjust column widths to the available window if a group is applied. I have a series of columns, most of which are Width="Auto", but one of which is Width="*". If I resize the window to allow the * column to expand, then try to reduce the width while a grouping is applied, the horizontal scroll bar flashes and the application freezes. Sometimes it comes back, sometimes it doesn't. Sometimes switching to another window and back seems to help, sometimes it doesn't.

    Pausing the debugger while this is occurring (which is only possible some of the time; sometimes Visual Studio is frozen as well) tries to open the file:

    c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\ScrollViewer\GridViewScrollViewer.cs

    The call stack is:
    [External Code]
    Telerik.Windows.Controls.GridView.dll!Telerik.Windows.Controls.GridView.GridViewScrollViewer.MeasureOverride(System.Windows.Size availableSize) Line 202 + 0x25 bytes    C#
    [External Code]

    The problem does not occur if the * column is switched to Auto, or if the Grouping is not applied. It also doesn't seem to happen if no vertical scrolling is necessary.

    I am using 2013_3_1209, but have verified the problem still occurs with 2014_1_0224. Below is a simple application which exhibits the problem when you try to reduce the width of the window.

    Is there any known way to work around this issue using other settings while achieving the same effect?

    <Window x:Class="Scroll.MainWindow"
            Title="MainWindow" Height="350" Width="500">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <telerik:RadGridView ItemsSource="{Binding Path=Items}" AutoGenerateColumns="False" AutoExpandGroups="True"
                                     VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                <telerik:RadGridView.GroupDescriptors>
                    <telerik:GroupDescriptor Member="Group" />
                </telerik:RadGridView.GroupDescriptors>
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Path=Name}" Width="Auto" />
                    <telerik:GridViewDataColumn Header="Number" DataMemberBinding="{Binding Path=Number}" Width="*" />
                    <telerik:GridViewDataColumn Header="Group" DataMemberBinding="{Binding Path=Group}" Width="Auto" />
                    <telerik:GridViewDataColumn Header="Text" DataMemberBinding="{Binding Path=Text}" Width="Auto" />
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
        </Grid>
    </Window>

    using System.Collections.ObjectModel;
    using System.Windows;
     
    namespace Scroll
    {
        public class Item
        {
            public string Name { get; set; }
            public int Number { get; set; }
            public string Group { get; set; }
            public string Text { get; set; }
        }
     
        public partial class MainWindow : Window
        {
            public ObservableCollection<Item> Items { get; set; }
     
            public MainWindow()
            {
                InitializeComponent();
                Items = new ObservableCollection<Item>();
                for (int i = 0; i < 25; i++)
                    Items.Add(new Item()
                    {
                        Name = "Object " + i,
                        Number = i,
                        Group = (i % 2 == 1 ? "Odd" : "Even"),
                        Text = "this is just some long text to make the window have to resize some things."
                    });
                DataContext = this;
            }
        }
    }
  2. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Mar 2014 Link to this post

    Hello,

    Would you please try setting RadGridView.GroupRenderMode mode to "Flat'? 
    You can find more information on the deference between both the modes in our online documentation:
    Grouping Render Modes.


    Regards,
    Didie
    Telerik
     

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Louis
    Louis avatar
    83 posts
    Member since:
    Aug 2013

    Posted 13 Mar 2014 in reply to Dimitrina Link to this post

    Thank you very much Didie, that indeed fixed the freezing problem. It is now leaving a disabled horizontal scroll bar sometimes (screenshot attached), but that is much preferred to freezing! I couldn't easily get the test app to exhibit the same behavior, but the real app uses CellTemplates containing Grids with some Auto and some * Width specifications.
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Mar 2014 Link to this post

    Hello,

    We fixed a similar issue with our latest version (2014.1.0224). Would you please test with it?

    Regards,
    Didie
    Telerik
     

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

     
  6. Louis
    Louis avatar
    83 posts
    Member since:
    Aug 2013

    Posted 13 Mar 2014 in reply to Dimitrina Link to this post

    The problem does indeed seem to be resolved in 2014.1.0224. That also explains why I couldn't reproduce it in the test app, which is using that version.

    Thank you again Didie!
    Louis
  7. Kim
    Kim avatar
    6 posts
    Member since:
    Nov 2013

    Posted 11 Jun 2014 in reply to Louis Link to this post

    i think wifth='*' not need HorizontalScroll.
    so it's option changed that ScrollViewer.HorizontalScrollBarVisibility="Hidden".
  8. Louis
    Louis avatar
    83 posts
    Member since:
    Aug 2013

    Posted 11 Jun 2014 in reply to Kim Link to this post

    width="*" just means that column will resize as the grid is resized. That doesn't stop the user from resizing the window to be too small for the grid to fit (including the non-scaling columns). If this occurs, the scroll bars are needed.
Back to Top
UI for WPF is Visual Studio 2017 Ready