WP7 Pivot control and a WebBrowser control

前端 未结 4 699
-上瘾入骨i
-上瘾入骨i 2020-12-10 23:14

I have a Pivot which contains a WebBrowser control that practically takes up the whole page (appart from the Pivot header of course).

I would like to figure out how

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-10 23:51

    Call the below method and pass your parameter as PivotControl x:name and WebBrowserControl x:name to this method.

    Here the WebBrowserControl is placed in second pivot item i.e. Pivot Index is 1 and I am trying to swipe left or right and reach to pivot index 2 or 1 respectively.

    public static void SwipteLeftRight(Microsoft.Phone.Controls.Pivot pivotControl, Microsoft.Phone.Controls.WebBrowser webBrowserControl)        
            {
                var gesListener = GestureService.GetGestureListener(webBrowserControl);
                gesListener.Flick += ((sen, args) =>
                {
                    if (args.Direction == System.Windows.Controls.Orientation.Horizontal)
                    {
                        if (args.HorizontalVelocity < 0)
                        {
    
                            if (((Microsoft.Phone.Controls.PivotItem)(pivotControl.SelectedItem)).Header.ToString().Trim() == "Pivot Item name")
                            {
                                pivotControl.SelectedIndex = 2; //Next Pivot item
                            }
                        }
                        else if (args.HorizontalVelocity > 0)
                        {
    
                            if ((Microsoft.Phone.Controls.PivotItem)(pivotControl.SelectedItem)).Header.ToString().Trim() == "Pivot Item name")
                            {
                                pivotControl.SelectedIndex = 0; // Previous Pivot Item
                            }
                        }
                    }
                });
            }
    

    It worked for me. Cheers

提交回复
热议问题