diff options
author | Jimmy Garrido <jimmygarrido@outlook.com> | 2017-03-06 14:19:36 -0800 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2017-03-10 14:52:17 +0000 |
commit | 8ea3368ff91b79f8e64814f98722d5aac7412f55 (patch) | |
tree | 02b26563e3a732577d7d873a0e864b00f296d06d /Xamarin.Forms.Platform.UAP | |
parent | d455bc42eaf79edb2dc0bb3b5a194fc91a98f96d (diff) | |
download | xamarin-forms-8ea3368ff91b79f8e64814f98722d5aac7412f55.tar.gz xamarin-forms-8ea3368ff91b79f8e64814f98722d5aac7412f55.tar.bz2 xamarin-forms-8ea3368ff91b79f8e64814f98722d5aac7412f55.zip |
[UWP] Improve toolbar consistency on MasterDetailPage (#744)
* Improve toolbar consistency on MasterDetailPage
* Properly indent xaml page
Diffstat (limited to 'Xamarin.Forms.Platform.UAP')
-rw-r--r-- | Xamarin.Forms.Platform.UAP/MasterDetailControl.cs | 3 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.UAP/MasterDetailControlStyle.xaml | 34 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.UAP/MasterDetailPageRenderer.cs | 28 |
3 files changed, 34 insertions, 31 deletions
diff --git a/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs b/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs index 79da59cb..56dd4d94 100644 --- a/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs +++ b/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs @@ -294,6 +294,9 @@ namespace Xamarin.Forms.Platform.UWP ContentTogglePaneButtonVisibility = _split.DisplayMode == SplitViewDisplayMode.Overlay ? Visibility.Visible : Visibility.Collapsed; + + if (ContentTogglePaneButtonVisibility == Visibility.Visible) + DetailTitleVisibility = Visibility.Visible; } } }
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.UAP/MasterDetailControlStyle.xaml b/Xamarin.Forms.Platform.UAP/MasterDetailControlStyle.xaml index 3f13f76f..ee51204c 100644 --- a/Xamarin.Forms.Platform.UAP/MasterDetailControlStyle.xaml +++ b/Xamarin.Forms.Platform.UAP/MasterDetailControlStyle.xaml @@ -29,26 +29,26 @@ <RowDefinition Height="Auto" /> </Grid.RowDefinitions> - <Border x:Name="TopCommandBarArea" HorizontalAlignment="Stretch" Background="{TemplateBinding ToolbarBackground}"> - <uwp:FormsCommandBar x:Name="CommandBar" Background="{TemplateBinding ToolbarBackground}" MinHeight="{ThemeResource TitleBarHeight}"> - <uwp:FormsCommandBar.Content> - <Border x:Name="TitleArea" Height="{ThemeResource TitleBarHeight}"> - <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Background="{TemplateBinding ToolbarBackground}" > + <Border x:Name="TopCommandBarArea" HorizontalAlignment="Stretch" Background="{TemplateBinding ToolbarBackground}"> + <uwp:FormsCommandBar x:Name="CommandBar" Background="{TemplateBinding ToolbarBackground}" MinHeight="{ThemeResource TitleBarHeight}"> + <uwp:FormsCommandBar.Content> + <Border x:Name="TitleArea" Height="{ThemeResource TitleBarHeight}" Visibility="{TemplateBinding DetailTitleVisibility}"> + <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Background="{TemplateBinding ToolbarBackground}" > - <Button Name="ContentTogglePane" Style="{ThemeResource PaneButton}" Foreground="{TemplateBinding ToolbarForeground}" - Visibility="{TemplateBinding ContentTogglePaneButtonVisibility}" /> + <Button Name="ContentTogglePane" Style="{ThemeResource PaneButton}" Foreground="{TemplateBinding ToolbarForeground}" + Visibility="{TemplateBinding ContentTogglePaneButtonVisibility}" /> - <Border Height="{ThemeResource TitleBarHeight}" Visibility="{TemplateBinding DetailTitleVisibility}"> - <TextBlock Text="{TemplateBinding DetailTitle}" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="{TemplateBinding ToolbarForeground}" Style="{ThemeResource TitleTextBlockStyle}" /> - </Border> + <Border Height="{ThemeResource TitleBarHeight}" Visibility="{TemplateBinding DetailTitleVisibility}"> + <TextBlock Text="{TemplateBinding DetailTitle}" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="{TemplateBinding ToolbarForeground}" Style="{ThemeResource TitleTextBlockStyle}" /> + </Border> - </StackPanel> - </Border> - </uwp:FormsCommandBar.Content> - </uwp:FormsCommandBar> - </Border> + </StackPanel> + </Border> + </uwp:FormsCommandBar.Content> + </uwp:FormsCommandBar> + </Border> - <ContentPresenter x:Name="DetailPresenter" Grid.Row="1" Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Detail}" /> + <ContentPresenter x:Name="DetailPresenter" Grid.Row="1" Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Detail}" /> <Border x:Name="BottomCommandBarArea" Grid.Row="2" HorizontalAlignment="Stretch"></Border> </Grid> @@ -58,4 +58,4 @@ </Setter.Value> </Setter> </Style> -</ResourceDictionary>
\ No newline at end of file +</ResourceDictionary>
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.UAP/MasterDetailPageRenderer.cs b/Xamarin.Forms.Platform.UAP/MasterDetailPageRenderer.cs index e024b235..0faec61d 100644 --- a/Xamarin.Forms.Platform.UAP/MasterDetailPageRenderer.cs +++ b/Xamarin.Forms.Platform.UAP/MasterDetailPageRenderer.cs @@ -141,19 +141,17 @@ namespace Xamarin.Forms.Platform.UWP } e.NewElement.PropertyChanged += OnElementPropertyChanged; + UpdateMode(); UpdateDetail(); UpdateMaster(); - UpdateMode(); UpdateIsPresented(); if (!string.IsNullOrEmpty(e.NewElement.AutomationId)) Control.SetValue(AutomationProperties.AutomationIdProperty, e.NewElement.AutomationId); -#if WINDOWS_UWP - UpdateToolbarPlacement(); -#endif - - } + ((ITitleProvider)this).BarBackgroundBrush = (Brush)Windows.UI.Xaml.Application.Current.Resources["SystemControlBackgroundChromeMediumLowBrush"]; + UpdateToolbarPlacement(); + } } protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) @@ -262,8 +260,7 @@ namespace Xamarin.Forms.Platform.UWP IVisualElementRenderer renderer = _detail.GetOrCreateRenderer(); element = renderer.ContainerElement; - // Enforce consistency rules on toolbar (show toolbar if Detail is Navigation Page) - Control.ShouldShowToolbar = _detail is NavigationPage; + UpdateToolbarVisibilty(); } Control.Detail = element; @@ -301,24 +298,28 @@ namespace Xamarin.Forms.Platform.UWP Control.Master = element; Control.MasterTitle = _master?.Title; - // Enforce consistency rules on toolbar (show toolbar if Master is Navigation Page) - Control.ShouldShowToolbar = _master is NavigationPage; + UpdateToolbarVisibilty(); } void UpdateMode() { + UpdateDetailTitle(); Control.CollapseStyle = Element.OnThisPlatform().GetCollapseStyle(); Control.CollapsedPaneWidth = Element.OnThisPlatform().CollapsedPaneWidth(); Control.ShouldShowSplitMode = MasterDetailPageController.ShouldShowSplitMode; } -#if WINDOWS_UWP - - void UpdateToolbarPlacement() + void UpdateToolbarPlacement() { Control.ToolbarPlacement = Element.OnThisPlatform().GetToolbarPlacement(); } + void UpdateToolbarVisibilty() + { + // Enforce consistency rules on toolbar + Control.ShouldShowToolbar = _detail is NavigationPage || _master is NavigationPage; + } + public void BindForegroundColor(AppBar appBar) { SetAppBarForegroundBinding(appBar); @@ -334,6 +335,5 @@ namespace Xamarin.Forms.Platform.UWP element.SetBinding(Windows.UI.Xaml.Controls.Control.ForegroundProperty, new Windows.UI.Xaml.Data.Binding { Path = new PropertyPath("Control.ToolbarForeground"), Source = this, RelativeSource = new RelativeSource { Mode = RelativeSourceMode.TemplatedParent } }); } -#endif } }
\ No newline at end of file |