summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT.Phone/FormsPivot.cs
diff options
context:
space:
mode:
authorJason Smith <jason.smith@xamarin.com>2016-03-22 13:02:25 -0700
committerJason Smith <jason.smith@xamarin.com>2016-03-22 16:13:41 -0700
commit17fdde66d94155fc62a034fa6658995bef6fd6e5 (patch)
treeb5e5073a2a7b15cdbe826faa5c763e270a505729 /Xamarin.Forms.Platform.WinRT.Phone/FormsPivot.cs
downloadxamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.gz
xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.bz2
xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.zip
Initial import
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