summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.UAP/FormsCommandBar.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.UAP/FormsCommandBar.cs')
-rw-r--r--Xamarin.Forms.Platform.UAP/FormsCommandBar.cs19
1 files changed, 5 insertions, 14 deletions
diff --git a/Xamarin.Forms.Platform.UAP/FormsCommandBar.cs b/Xamarin.Forms.Platform.UAP/FormsCommandBar.cs
index 2ca665af..21e9ca16 100644
--- a/Xamarin.Forms.Platform.UAP/FormsCommandBar.cs
+++ b/Xamarin.Forms.Platform.UAP/FormsCommandBar.cs
@@ -6,32 +6,23 @@ namespace Xamarin.Forms.Platform.UWP
{
public class FormsCommandBar : CommandBar
{
- Windows.UI.Xaml.Controls.Button _moreButton;
+ // TODO Once 10.0.14393.0 is available, enable dynamic overflow: https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.commandbar.isdynamicoverflowenabled.aspx
public FormsCommandBar()
{
PrimaryCommands.VectorChanged += OnCommandsChanged;
SecondaryCommands.VectorChanged += OnCommandsChanged;
- }
-
- protected override void OnApplyTemplate()
- {
- base.OnApplyTemplate();
- _moreButton = GetTemplateChild("MoreButton") as Windows.UI.Xaml.Controls.Button;
- UpdateMore();
+ UpdateVisibility();
}
void OnCommandsChanged(IObservableVector<ICommandBarElement> sender, IVectorChangedEventArgs args)
{
- UpdateMore();
+ UpdateVisibility();
}
- void UpdateMore()
+ void UpdateVisibility()
{
- if (_moreButton == null)
- return;
-
- _moreButton.Visibility = PrimaryCommands.Count > 0 || SecondaryCommands.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
+ Visibility = PrimaryCommands.Count + SecondaryCommands.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
}
}
} \ No newline at end of file