GridView

2 posts, 0 answers
  1. Lucas
    Lucas avatar
    1 posts
    Member since:
    Apr 2016

    Posted 05 Apr Link to this post

    When a cell has  multi-lined wrapped text, and both vertical and grid extends beyond window size (have both vertical and horizontal scroll):

    Scrolling vertical scroll to the bottom, then horizontal to the right causes the vertical scrollbar to jump away from bottom.

    XAML

    <Window x:Class="GridScrollbarIssue.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
            xmlns:TelerikGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
            DataContext="{Binding RelativeSource={RelativeSource Self}}"
            Title="MainWindow" Height="350" Width="400">   
        
        <Grid>
            <TelerikGridView:RadGridView ItemsSource="{Binding Collection}" AutoGenerateColumns="False">
                <TelerikGridView:RadGridView.Columns>
                    <TelerikGridView:GridViewDataColumn Header="Column 1" DataMemberBinding="{Binding Col1}" Width="125" IsFilterable="True" >
                        
                    </TelerikGridView:GridViewDataColumn>                    
                <TelerikGridView:GridViewDataColumn Header="Column 2"  DataMemberBinding="{Binding Col2}" Width="125" IsFilterable="True" >
                        
                    </TelerikGridView:GridViewDataColumn>             
                <TelerikGridView:GridViewDataColumn Header="Column 3"  DataMemberBinding="{Binding Col3}" Width="125" IsFilterable="True" >
                        
                    </TelerikGridView:GridViewDataColumn>             
                <TelerikGridView:GridViewDataColumn Header="Column 4"  DataMemberBinding="{Binding Col4}" Width="125" IsFilterable="True" >
                        
                    </TelerikGridView:GridViewDataColumn>
                    <TelerikGridView:GridViewDataColumn Header="Column 5" DataMemberBinding="{Binding Col5}" Width="125" IsFilterable="True" TextWrapping="Wrap">
                        
                    </TelerikGridView:GridViewDataColumn>                    
                </TelerikGridView:RadGridView.Columns>
            </TelerikGridView:RadGridView>
        </Grid>
    </Window>

     

    C#:
    using System.Collections.ObjectModel;
    using System.Windows;

    namespace GridScrollbarIssue
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public ObservableCollection<Model> Collection { get; set; }
            public MainWindow()
            {
                Collection = CreateCollection();

                InitializeComponent();            
            }

            private static ObservableCollection<Model> CreateCollection()
            {
                return new ObservableCollection<Model>
                {
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},               
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                    new Model {Col1 = "", Col2 = "col2", Col3 = "col3", Col4 = "col4", Col5 = ""},
                     new Model
                    {
                        Col1 = "",
                        Col2 = "col2",
                        Col3 = "col3",
                        Col4 = "col4",
                        Col5 =
                            "test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test "
                    },
                };
            }
        }

        public class Model
        {
            public string Col1 { get; set; }
            public string Col2 { get; set; }
            public string Col3 { get; set; }
            public string Col4 { get; set; }
            public string Col5 { get; set; }
        }
    }


  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 07 Apr Link to this post

    Hi Lucas,

    Actually, this would be the expected behavior as that particular cell starts participating on the scroll info calculation when it is realized and about to be displayed. And since its height is more that the default one, there should be a recalculation of the scrolling behavior so that you can scroll to the bottom and see its whole content. 

    Regards,
    Maya
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top