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

RadDataPager with ListBox

2 Answers 180 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Yu
Top achievements
Rank 1
Yu asked on 23 Dec 2011, 10:18 AM
.xaml:
            <ListBox Name="itemsControl" ItemsSource="{Binding PagedSource, ElementName=radDataPager}"/>
            <telerik:RadDataPager Name="radDataPager" Height="30" VerticalAlignment="Bottom"
               Source="{Binding myItemsSource}"
               PageSize="10"
               DisplayMode="All"/>
.cs:
            List<string> list = new List<string>();
              
            for (int i = 0; i < 36; i++)
            {
                list.Add(i.ToString());
            }
              
            this.radDataPager.Source = list;

Hi,
Now I got a problem that using ListBox with RadDataPager,When turn the lastpage to previouspage(for example,the last page only have 1 item),the previouspage's itemcount turn to 1,how could I fix that?Here is a demo code above,with telerik 2010 Q2,Thanks.

 

Best Wishes,

Sky

2 Answers, 1 is accepted

Sort by
0
Accepted
Pavel Pavlov
Telerik team
answered on 28 Dec 2011, 02:19 PM
Hi Yu Sky,

It seems you have hit a bug in the ListBox . I have double checked for a problem in  our RadDataPager , but it appears an issue with the ListBox.
To check this , you can add a simple TextBlock bound to the count of the paged source. You will definitely see it shows the correct count,

Now the solution :

You may subscribe to the PageIndexChanged  event of RadDataPager and reset the source of the list box inside the event handler , such as :

    this.radDataPager.PageIndexChanged += new EventHandler<Telerik.Windows.Controls.PageIndexChangedEventArgs>(radDataPager_PageIndexChanged);
}
 
void radDataPager_PageIndexChanged(object sender, Telerik.Windows.Controls.PageIndexChangedEventArgs e)
{
    var cachedSource = this.itemsControl.ItemsSource;
    this.itemsControl.ItemsSource = null;
    this.itemsControl.ItemsSource = cachedSource;
}


All the best,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Yu
Top achievements
Rank 1
answered on 30 Dec 2011, 03:07 AM
Hi Pavel,
Thanks for reply! Is this because of the ItemSource has not refreshed when the page index has changed? This works,thanks.

Best Wishes to Telerik Team,
Sky 
Tags
DataPager
Asked by
Yu
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Yu
Top achievements
Rank 1
Share this question
or