Problem with scrolling

1 posts, 0 answers
  1. Andrew
    Andrew avatar
    20 posts
    Member since:
    Mar 2010

    Posted 27 Oct 2011 Link to this post

    Hello,

    I have found a problem with scrolling.

    My program:

    <Grid.RowDefinitions>
         <RowDefinition Height="*" />
         <RowDefinition Height="*" />
    </Grid.RowDefinitions>
     
    <telerik:RadGridView Grid.Row="0" Margin="10" x:Name="rg1" />
    <telerik:RadGridView Grid.Row="1" Margin="10" x:Name="rg2" />

    public class Item
    {
         public int Column1 { get; set; }
         public int Column2 { get; set; }
         public string Column3 { get; set; }
         public string Column4 { get; set; }
         public string Column5 { get; set; }
         public string Column6 { get; set; }
         public string Column7 { get; set; }
         public string Column8 { get; set; }
         public string Column9 { get; set; }
         public string Column10 { get; set; }
    }

    Dictionary<int, Item> data1 = new Dictionary<int, Item>();
    Dictionary<int, Item> data2 = new Dictionary<int, Item>();
     
    public MainPage()
    {
         InitializeComponent();
     
         rg1.SelectionChanged += new EventHandler<SelectionChangeEventArgs>(rg1_SelectionChanged);
         rg1.SelectionMode = System.Windows.Controls.SelectionMode.Single;
         rg1.SelectionUnit = Telerik.Windows.Controls.GridView.GridViewSelectionUnit.FullRow;
     
         SortDescriptor sd = new SortDescriptor();
         sd.Member = "Column2";
         sd.SortDirection = System.ComponentModel.ListSortDirection.Ascending;
         rg1.SortDescriptors.Add(sd);
     
         SetColumns();
         LoadData();
    }
     
    void rg1_SelectionChanged(object sender, SelectionChangeEventArgs e)
    {
         Random rand = new Random();
     
         data2.Clear();
         for (int i = 0; i < 10; i++)
         {
              Item it = new Item();
              it.Column1 = i;
              it.Column2 = rand.Next();
              data2.Add(i, it);
         }
     
         try
         {
              rg2.ItemsSource = data2.Values;
              rg2.Rebind();
         }
         catch (Exception ex)
         {
              MessageBox.Show(ex.Message);
         }
    }
     
    private void SetColumns()
    {
         rg1.AutoGenerateColumns = false;
         rg2.AutoGenerateColumns = false;
     
         GridViewDataColumn column1 = new GridViewDataColumn();
         column1.Header = "Column1";
         column1.UniqueName = "Column1";
         rg1.Columns.Add(column1);
     
         GridViewDataColumn column2 = new GridViewDataColumn();
         column2.Header = "Column2";
         column2.UniqueName = "Column2";
         rg1.Columns.Add(column2);
     
         GridViewDataColumn column3 = new GridViewDataColumn();
         column3.Header = "Column3";
         column3.UniqueName = "Column3";
         rg1.Columns.Add(column3);
     
         GridViewDataColumn column4 = new GridViewDataColumn();
         column4.Header = "Column4";
         column4.UniqueName = "Column4";
         rg1.Columns.Add(column4);
          
         GridViewDataColumn column5 = new GridViewDataColumn();
         column5.Header = "Column5";
         column5.UniqueName = "Column5";
         rg1.Columns.Add(column5);
     
         GridViewDataColumn column6 = new GridViewDataColumn();
         column6.Header = "Column6";
         column6.UniqueName = "Column6";
         column6.Width = 130;
         column6.TextWrapping = TextWrapping.Wrap;
         rg1.Columns.Add(column6);
     
         GridViewDataColumn column7 = new GridViewDataColumn();
         column7.Header = "Column7";
         column7.UniqueName = "Column7";
         column7.Width = 130;
         column7.TextWrapping = TextWrapping.Wrap;
         rg1.Columns.Add(column7);
     
         GridViewDataColumn column8 = new GridViewDataColumn();
         column8.Header = "Column8";
         column8.UniqueName = "Column8";
         column8.Width = 130;
         column8.TextWrapping = TextWrapping.Wrap;
         rg1.Columns.Add(column8);
     
         GridViewDataColumn column9 = new GridViewDataColumn();
         column9.Header = "Column9";
         column9.UniqueName = "Column9";
         column9.Width = 130;
         column9.TextWrapping = TextWrapping.Wrap;
         rg1.Columns.Add(column9);
     
         GridViewDataColumn column10 = new GridViewDataColumn();
         column10.Header = "Column10";
         column10.UniqueName = "Column10";
         rg1.Columns.Add(column10);
     
     
         GridViewDataColumn column33 = new GridViewDataColumn();
         column33.Header = "Column1";
         column33.UniqueName = "Column1";
         rg2.Columns.Add(column33);
     
         GridViewDataColumn column34 = new GridViewDataColumn();
         column34.Header = "Column2";
         column34.UniqueName = "Column2";
         rg2.Columns.Add(column34);
     
     
         Telerik.Windows.Data.GroupDescriptor gd = new Telerik.Windows.Data.GroupDescriptor();
         gd.Member = "Column2";
         gd.DisplayContent = "Column2";
     
         rg2.GroupDescriptors.Add(gd);
    }
     
    private void LoadData()
    {
         Random rand = new Random();
     
         data1.Clear();
         for (int i = 0; i < 100; i++)
         {
              Item it = new Item();
              it.Column1 = i;
              it.Column2 = rand.Next();
              it.Column3 = "ad sdf sfef esfsf eawda wd awd awdawdawdawd awd asddaaaaaaaaaaaaaaaaaaa efefs daawwwwwwwwwwwwwwwwwwwwwwwwwww wewewewewewewe";
              it.Column4 = "asdasda aef hyjdtyjawdad dwd  ddddddddddddd";
              it.Column5 = "asda w adawdwd awd dawdawd awdawda dw adawda awd";
              it.Column6 = "aaaaaaaaaaaaa addddddddddddddddddddddddddddd";
              it.Column7 = "asd dddddddddddddddddd ddd";
              it.Column8 = "asd ddddawd aw ad yyjgyujy uj thdrgdrg drg drg";
              it.Column9 = "asdasd asda sdasd asd dwe fefsefsef ppppppppppppppppppppppppppppp";
              it.Column10 = "asdad yj,vb,vb,vb, vb cb  cvb cvbcvbcvbc cvbcvb";
              data1.Add(i, it);
         }
     
         rg1.ItemsSource = data1.Values;
         rg1.Rebind();
     
         foreach (var item in data1)
         {
              rg1.SelectedItems.Add(data1[int.Parse(item.Key.ToString())]);
              break;
         }
    }


    Select last visible row and then use right arrow key to change selected cell. After few moves the upper grid looses focus (bottom grid has it). 

Back to Top