summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT.Phone/FormsPivot.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT.Phone/FormsPivot.cs')
-rw-r--r--Xamarin.Forms.Platform.WinRT.Phone/FormsPivot.cs65
1 files changed, 65 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT.Phone/FormsPivot.cs b/Xamarin.Forms.Platform.WinRT.Phone/FormsPivot.cs
new file mode 100644
index 00000000..d829b787
--- /dev/null
+++ b/Xamarin.Forms.Platform.WinRT.Phone/FormsPivot.cs
@@ -0,0 +1,65 @@
+´╗┐using System.Threading.Tasks;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Media;
+
+#if WINDOWS_UWP
+
+namespace Xamarin.Forms.Platform.UWP
+#else
+namespace Xamarin.Forms.Platform.WinRT
+#endif
+{
+ public class FormsPivot : Pivot, IToolbarProvider
+ {
+ public static readonly DependencyProperty ToolbarVisibilityProperty = DependencyProperty.Register("ToolbarVisibility", typeof(Visibility), typeof(FormsPivot),
+ new PropertyMetadata(Visibility.Collapsed));
+
+ public static readonly DependencyProperty ToolbarForegroundProperty = DependencyProperty.Register("ToolbarForeground", typeof(Brush), typeof(FormsPivot), new PropertyMetadata(default(Brush)));
+
+ public static readonly DependencyProperty ToolbarBackgroundProperty = DependencyProperty.Register("ToolbarBackground", typeof(Brush), typeof(FormsPivot), new PropertyMetadata(default(Brush)));
+
+ CommandBar _commandBar;
+
+ TaskCompletionSource<CommandBar> _commandBarTcs;
+
+ public Brush ToolbarBackground
+ {
+ get { return (Brush)GetValue(ToolbarBackgroundProperty); }
+ set { SetValue(ToolbarBackgroundProperty, value); }
+ }
+
+ public Brush ToolbarForeground
+ {
+ get { return (Brush)GetValue(ToolbarForegroundProperty); }
+ set { SetValue(ToolbarForegroundProperty, value); }
+ }
+
+ public Visibility ToolbarVisibility
+ {
+ get { return (Visibility)GetValue(ToolbarVisibilityProperty); }
+ set { SetValue(ToolbarVisibilityProperty, value); }
+ }
+
+ Task<CommandBar> IToolbarProvider.GetCommandBarAsync()
+ {
+ if (_commandBar != null)
+ return Task.FromResult(_commandBar);
+
+ _commandBarTcs = new TaskCompletionSource<CommandBar>();
+ ApplyTemplate();
+ return _commandBarTcs.Task;
+ }
+
+ protected override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+ _commandBar = GetTemplateChild("CommandBar") as CommandBar;
+ TaskCompletionSource<CommandBar> tcs = _commandBarTcs;
+ if (tcs != null)
+ {
+ tcs.SetResult(_commandBar);
+ }
+ }
+ }
+} \ No newline at end of file