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.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.UAP/FormsCommandBar.cs b/Xamarin.Forms.Platform.UAP/FormsCommandBar.cs
new file mode 100644
index 00000000..2ca665af
--- /dev/null
+++ b/Xamarin.Forms.Platform.UAP/FormsCommandBar.cs
@@ -0,0 +1,37 @@
+´╗┐using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+
+namespace Xamarin.Forms.Platform.UWP
+{
+ public class FormsCommandBar : CommandBar
+ {
+ Windows.UI.Xaml.Controls.Button _moreButton;
+
+ public FormsCommandBar()
+ {
+ PrimaryCommands.VectorChanged += OnCommandsChanged;
+ SecondaryCommands.VectorChanged += OnCommandsChanged;
+ }
+
+ protected override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+ _moreButton = GetTemplateChild("MoreButton") as Windows.UI.Xaml.Controls.Button;
+ UpdateMore();
+ }
+
+ void OnCommandsChanged(IObservableVector<ICommandBarElement> sender, IVectorChangedEventArgs args)
+ {
+ UpdateMore();
+ }
+
+ void UpdateMore()
+ {
+ if (_moreButton == null)
+ return;
+
+ _moreButton.Visibility = PrimaryCommands.Count > 0 || SecondaryCommands.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
+ }
+ }
+} \ No newline at end of file