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

Gesture to scroll on a RadPageView

4 Answers 189 Views
PageView
This is a migrated thread and some comments may be shown as answers.
OD
Top achievements
Rank 1
OD asked on 28 Oct 2015, 04:15 PM

Hi, 

I currently develop an application on Windows 10 on a tactile device uses a RadPageView (explorerBar mode).

I want to use gesture to control the scroll, i set the enableGesture to Pan.

And in PanGesture event, i have the code :

   

If CType(CType(sender, RadPageView).GetChildAt(0).GetChildAt(3), Telerik.WinControls.UI.RadScrollBarElement).Visibility = ElementVisibility.Visible Then
          If CType(CType(sender, RadPageView).GetChildAt(0).GetChildAt(3), Telerik.WinControls.UI.RadScrollBarElement).Value + e.Offset.Height >= CType(sender, RadPageView).VerticalScroll.Minimum And _
             CType(CType(sender, RadPageView).GetChildAt(0).GetChildAt(3), Telerik.WinControls.UI.RadScrollBarElement).Value + e.Offset.Height <= CType(sender, RadPageView).VerticalScroll.Maximum Then
              CType(sender, RadPageView).VerticalScroll.Value = CType(CType(sender, RadPageView).GetChildAt(0).GetChildAt(3), Telerik.WinControls.UI.RadScrollBarElement).Value + e.Offset.Height
          End If
          CType(CType(sender, RadPageView).GetChildAt(0).GetChildAt(3), Telerik.WinControls.UI.RadScrollBarElement).Value += e.Offset.Height
      End If

Only the scroll bar moves, not the control

 Thanks for your help :)

NB : I'm using Q1-2015

4 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 30 Oct 2015, 09:01 AM
Hi ,

Thank you for writing.

You need to call the InvalidateMeasure method in order to properly update the view after the scroll value is set:
Private Sub radPageView1_PanGesture(ByVal sender As Object, ByVal e As Telerik.WinControls.PanGestureEventArgs)
    Dim el As RadPageViewExplorerBarElement = TryCast(Me.radPageView1.ViewElement, RadPageViewExplorerBarElement)
 
    If el.Scrollbar.IsElementVisible Then
        e.Handled = True
        If e.Offset.Height > 0 AndAlso el.Scrollbar.Value + 10 < el.Scrollbar.Maximum Then
            el.Scrollbar.Value += 10
            el.InvalidateMeasure()
        End If
        If e.Offset.Height < 0 AndAlso el.Scrollbar.Value - 10 >= 0 Then
            el.Scrollbar.Value -= 10
            el.InvalidateMeasure()
        End If
    End If
End Sub

Please let me know if there is something else I can help you with. 
 
Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
OD
Top achievements
Rank 1
answered on 30 Oct 2015, 04:31 PM
Many thanks, works like a charm :)
0
Fahmi
Top achievements
Rank 1
Veteran
answered on 03 Oct 2020, 03:19 PM

Hi Dimitar,

Could you please provide me the same functionality in C# ( Telerik winforms ).
Thanks,

Fahmi

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Oct 2020, 08:28 AM

Hello, Fahmi,

You can find below the code in C#:

        private void RadPageView1_PanGesture(object sender, PanGestureEventArgs e)
        { 
            RadPageViewExplorerBarElement el = this.radPageView1.ViewElement as RadPageViewExplorerBarElement;

            if (el.Scrollbar.IsElementVisible)
            {
                e.Handled = true;
                if (e.Offset.Height > 0 && el.Scrollbar.Value + 10 < el.Scrollbar.Maximum)
                {
                    el.Scrollbar.Value += 10;
                    el.InvalidateMeasure();
                }
                if (e.Offset.Height < 0 && el.Scrollbar.Value - 10 >= 0)
                {
                    el.Scrollbar.Value -= 10;
                    el.InvalidateMeasure();
                }
            }
        }

Feel free to use the free Telerik Code Converter if you need any further code converting: https://converter.telerik.com/ 

I hope this information helps.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
PageView
Asked by
OD
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
OD
Top achievements
Rank 1
Fahmi
Top achievements
Rank 1
Veteran
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or