private void ChangeItemsPanel(AutoRotateGridViewLayouts layout) { switch (layout) { case AutoRotateGridViewLayouts.Minimal: if (this.MinimalItemsPanel != null) { this.ItemsPanel = this.MinimalItemsPanel; } else { this.ChangeItemsPanel(AutoRotateGridViewLayouts.Portrait); } break; case AutoRotateGridViewLayouts.Portrait: if (this.PortraitItemsPanel != null) { this.ItemsPanel = this.PortraitItemsPanel; } else { this.ChangeItemsPanel(AutoRotateGridViewLayouts.Landscape); } break; case AutoRotateGridViewLayouts.Landscape: this.ItemsPanel = landscapeItemsPanel; break; } }
private void ChangeGroupStyle(AutoRotateGridViewLayouts layout) { switch (layout) { case AutoRotateGridViewLayouts.Minimal: if (this.MinimalGroupStyle != null && this.MinimalGroupStyle.Count > 0) { this.GroupStyle.Clear(); foreach (GroupStyle style in this.MinimalGroupStyle) { this.GroupStyle.Add(style); } } else { this.ChangeGroupStyle(AutoRotateGridViewLayouts.Portrait); } break; case AutoRotateGridViewLayouts.Portrait: if (this.PortraitGroupStyle != null && this.PortraitGroupStyle.Count > 0) { this.GroupStyle.Clear(); foreach (GroupStyle style in this.PortraitGroupStyle) { this.GroupStyle.Add(style); } } else { this.ChangeGroupStyle(AutoRotateGridViewLayouts.Landscape); } break; case AutoRotateGridViewLayouts.Landscape: this.GroupStyle.Clear(); if (this.landscapeGroupStyle != null) { foreach (GroupStyle style in this.landscapeGroupStyle) { this.GroupStyle.Add(style); } } break; } }
// Methods and handlers void RotatingGridview_SizeChanged(object sender, SizeChangedEventArgs e) { // We save the landscape styles as these properties will be changed later if (this.landscapeItemTemplate == null) { this.landscapeItemTemplate = this.ItemTemplate; } if (this.landscapeItemsPanel == null) { this.landscapeItemsPanel = this.ItemsPanel; } if (this.landscapeGroupStyle == null) { this.landscapeGroupStyle = new List <GroupStyle>(); foreach (GroupStyle style in this.GroupStyle) { this.landscapeGroupStyle.Add(style); } } // We search for the corresponding layout and update it if it changed if (this.MinimalLayoutWidth > Window.Current.Bounds.Width) { if (this.previousState != AutoRotateGridViewLayouts.Minimal) { this.previousState = AutoRotateGridViewLayouts.Minimal; UpdateLayout(AutoRotateGridViewLayouts.Minimal); } } else if (Window.Current.Bounds.Height > Window.Current.Bounds.Width) { if (this.previousState != AutoRotateGridViewLayouts.Portrait) { this.previousState = AutoRotateGridViewLayouts.Portrait; UpdateLayout(AutoRotateGridViewLayouts.Portrait); } } else { if (this.previousState != AutoRotateGridViewLayouts.Landscape) { this.previousState = AutoRotateGridViewLayouts.Landscape; UpdateLayout(AutoRotateGridViewLayouts.Landscape); } } }
private void UpdateLayout(AutoRotateGridViewLayouts layout) { // Landscape layout if (layout == AutoRotateGridViewLayouts.Landscape) { this.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Auto); this.SetValue(ScrollViewer.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); this.SetValue(ScrollViewer.HorizontalScrollModeProperty, ScrollMode.Enabled); this.SetValue(ScrollViewer.VerticalScrollModeProperty, ScrollMode.Disabled); this.SetValue(ScrollViewer.ZoomModeProperty, ZoomMode.Disabled); } else { this.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); this.SetValue(ScrollViewer.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Auto); this.SetValue(ScrollViewer.HorizontalScrollModeProperty, ScrollMode.Disabled); this.SetValue(ScrollViewer.VerticalScrollModeProperty, ScrollMode.Enabled); this.SetValue(ScrollViewer.ZoomModeProperty, ZoomMode.Disabled); } this.ChangeItemsPanel(layout); this.ChangeGroupStyle(layout); this.ChangeItemTemplate(layout); }
// Methods and handlers private void RotatingGridview_SizeChanged(object sender, SizeChangedEventArgs e) { // We save the landscape styles as these properties will be changed later if (this.landscapeItemTemplate == null) { this.landscapeItemTemplate = this.ItemTemplate; } if (this.landscapeItemsPanel == null) { this.landscapeItemsPanel = this.ItemsPanel; } if (this.landscapeGroupStyle == null) { this.landscapeGroupStyle = new List<GroupStyle>(); foreach (GroupStyle style in this.GroupStyle) { this.landscapeGroupStyle.Add(style); } } // We search for the corresponding layout and update it if it changed if (this.MinimalLayoutWidth > Window.Current.Bounds.Width) { if (this.previousState != AutoRotateGridViewLayouts.Minimal) { this.previousState = AutoRotateGridViewLayouts.Minimal; UpdateLayout(AutoRotateGridViewLayouts.Minimal); } } else if (Window.Current.Bounds.Height > Window.Current.Bounds.Width) { if (this.previousState != AutoRotateGridViewLayouts.Portrait) { this.previousState = AutoRotateGridViewLayouts.Portrait; UpdateLayout(AutoRotateGridViewLayouts.Portrait); } } else { if (this.previousState != AutoRotateGridViewLayouts.Landscape) { this.previousState = AutoRotateGridViewLayouts.Landscape; UpdateLayout(AutoRotateGridViewLayouts.Landscape); } } }