How to programmatically set selected Panorama item in WP7

后端 未结 6 683
春和景丽
春和景丽 2020-11-30 10:37

I\'m using a panorama control in a WP7 app. One of the PanoramaItems takes you to another page, which then allows you send an email through the EmailComposeTask. If you don\

6条回答
  •  庸人自扰
    2020-11-30 10:43

    I'm using this model to change to a pivot when the device goes into landscape view, I'll probably end up extracting the current item to the application state. The panorama is a no-go in landscape orientation.

    private int hub_page_index;
    
    protected override void OnOrientationChanged(OrientationChangedEventArgs e)
    {
        base.OnOrientationChanged(e);
    
        if (panorama.Visibility == Visibility.Visible)
        {
            hub_page_index = panorama.SelectedIndex;
        }
        else if (pivot.Visibility == Visibility.Visible)
        {
            hub_page_index = pivot.SelectedIndex;
        }
    
        if (e.Orientation == PageOrientation.Landscape
         || e.Orientation == PageOrientation.LandscapeLeft
         || e.Orientation == PageOrientation.LandscapeRight)
        {
        // Display Pivot in Landscape orientation
            pivot.SetValue(Pivot.SelectedItemProperty, pivot.Items[panorama.SelectedIndex]);
            panorama.Visibility = Visibility.Collapsed;
            pivot.Visibility = Visibility.Visible;
        }
        else
        {
            // Display Panorama in Portrait orientation
            panorama.SetValue(Panorama.SelectedItemProperty, panorama.Items[pivot.SelectedIndex]);
            pivot.Visibility = Visibility.Collapsed;
            panorama.Visibility = Visibility.Visible;
        }
    }
    

提交回复
热议问题