Setting the PageIndex in code behind and calling PageIndexChange event

2 posts, 0 answers
  1. Mathieu
    Mathieu avatar
    1 posts
    Member since:
    Oct 2011

    Posted 17 Feb 2012 Link to this post

    Hi,

    I am using the RadDataPager control in a grid manually without setting a PagedSource or a Source. I have a ViewModel Command connected to the PageIndexChange using a behavior I created and it works fine, but in the code-behind of my view I set the PageIndex of the control to 0 sometimes. This doesn't trigger the event, and in another thread it was said that this was by design, that only when the PageIndex is changed by the control itself it triggers.

    What I would expect though would be the event being called when the PageIndex is changed, whoever changed it. How could I get my Command to be called when I set the PageIndex myself without breaking the MVVM pattern? What I want to avoid is this in the code-behind of my view but it's the only thing I can think of to do what I want :

    public void ResetDataPager()
    {
        if (DataPager.PageIndex > 0)
        {
            DataPager.PageIndex = 0;
            // not MVVM
            var vm = (MyViewModel)DataPager.DataContext;
            vm.ChangePageIndex.Execute(DataPager.PageIndex);
        }
    }

    Do you have any idea how I can achieve this?
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 17 Feb 2012 Link to this post

    Hi,

    Can you open a new support ticket and send us a very dummy sample project with your exact implementation so we can take a look at it. Thanks in advance.

    Regards,
    Ross
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
Back to Top