diff options
author | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 13:02:25 -0700 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 16:13:41 -0700 |
commit | 17fdde66d94155fc62a034fa6658995bef6fd6e5 (patch) | |
tree | b5e5073a2a7b15cdbe826faa5c763e270a505729 /Xamarin.Forms.Platform.WinRT.Tablet | |
download | xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.gz xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.bz2 xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.zip |
Initial import
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT.Tablet')
14 files changed, 2122 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/Forms.cs b/Xamarin.Forms.Platform.WinRT.Tablet/Forms.cs new file mode 100644 index 00000000..cc5ef334 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Tablet/Forms.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using Windows.ApplicationModel.Activation; +using Windows.Foundation.Metadata; +using Windows.UI.Core; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Media; +#if WINDOWS_UWP +using Xamarin.Forms.Platform.UWP; + +#else +using Xamarin.Forms.Platform.WinRT; + +#endif + +namespace Xamarin.Forms +{ + public static class Forms + { + const string LogFormat = "[{0}] {1}"; + + static ApplicationExecutionState s_state; + static bool s_isInitialized; +#if WINDOWS_UWP + public static void Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable<Assembly> rendererAssemblies = null) +#else + public static void Init(IActivatedEventArgs launchActivatedEventArgs) +#endif + { + if (s_isInitialized) + return; + + var accent = (SolidColorBrush)Windows.UI.Xaml.Application.Current.Resources["SystemColorControlAccentBrush"]; + Color.Accent = Color.FromRgba(accent.Color.R, accent.Color.G, accent.Color.B, accent.Color.A); + + Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m))); + + Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(GetTabletResources()); + + Device.OS = TargetPlatform.Windows; + Device.Idiom = TargetIdiom.Tablet; + Device.PlatformServices = new WindowsPlatformServices(Window.Current.Dispatcher); + Device.Info = new WindowsDeviceInfo(); + +#if WINDOWS_UWP + switch (DetectPlatform()) + { + case Windows.Foundation.Metadata.Platform.Windows: + Device.Idiom = TargetIdiom.Desktop; + break; + case Windows.Foundation.Metadata.Platform.WindowsPhone: + Device.Idiom = TargetIdiom.Phone; + break; + default: + Device.Idiom = TargetIdiom.Tablet; + break; + } +#endif + Ticker.Default = new WindowsTicker(); + + ExpressionSearch.Default = new WindowsExpressionSearch(); + +#if WINDOWS_UWP + Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); +#endif + + Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); + + s_isInitialized = true; + s_state = launchActivatedEventArgs.PreviousExecutionState; + +#if WINDOWS_UWP + SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; +#endif + } + + static Windows.Foundation.Metadata.Platform DetectPlatform() + { +#if WINDOWS_UWP + bool isHardwareButtonsAPIPresent = ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"); + + if (isHardwareButtonsAPIPresent) + return Windows.Foundation.Metadata.Platform.WindowsPhone; +#endif + return Windows.Foundation.Metadata.Platform.Windows; + } + + static Windows.UI.Xaml.ResourceDictionary GetTabletResources() + { + return new Windows.UI.Xaml.ResourceDictionary { +#if !WINDOWS_UWP + Source = new Uri("ms-appx:///Xamarin.Forms.Platform.WinRT.Tablet/TabletResources.xbf") +#else + Source = new Uri("ms-appx:///Xamarin.Forms.Platform.UAP/Resources.xbf") +#endif + }; + } + +#if WINDOWS_UWP + static void OnBackRequested(object sender, BackRequestedEventArgs e) + { + Application app = Application.Current; + if (app == null) + return; + + Page page = app.MainPage; + if (page == null) + return; + + var platform = page.Platform as Platform.UWP.Platform; + if (platform == null) + return; + + e.Handled = platform.BackButtonPressed(); + } +#endif + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/FormsListViewItemPresenter.cs b/Xamarin.Forms.Platform.WinRT.Tablet/FormsListViewItemPresenter.cs new file mode 100644 index 00000000..1e308867 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Tablet/FormsListViewItemPresenter.cs @@ -0,0 +1,36 @@ +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; + +namespace Xamarin.Forms.Platform.WinRT +{ + // This exists to work around the fact that when you set these bindings in XAML and compile on Win10 + // the resulting xbf file does not load correctly on Win8.1. MS has acknowledged the issue but has no fixed it. + // This hacks around the problem. + public class FormsListViewItemPresenter : ListViewItemPresenter + { + public FormsListViewItemPresenter() + { + var verticalContentAlignBinding = new Windows.UI.Xaml.Data.Binding + { + Path = new PropertyPath("VerticalContentAlignment"), + RelativeSource = new RelativeSource { Mode = RelativeSourceMode.TemplatedParent } + }; + BindingOperations.SetBinding(this, VerticalContentAlignmentProperty, verticalContentAlignBinding); + + var paddingBinding = new Windows.UI.Xaml.Data.Binding + { + Path = new PropertyPath("Padding"), + RelativeSource = new RelativeSource { Mode = RelativeSourceMode.TemplatedParent } + }; + BindingOperations.SetBinding(this, PaddingProperty, paddingBinding); + + var contentTransitionBinding = new Windows.UI.Xaml.Data.Binding + { + Path = new PropertyPath("ContentTransitions"), + RelativeSource = new RelativeSource { Mode = RelativeSourceMode.TemplatedParent } + }; + BindingOperations.SetBinding(this, ContentTransitionsProperty, contentTransitionBinding); + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/FormsSearchBox.cs b/Xamarin.Forms.Platform.WinRT.Tablet/FormsSearchBox.cs new file mode 100644 index 00000000..633672f6 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Tablet/FormsSearchBox.cs @@ -0,0 +1,18 @@ +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace Xamarin.Forms.Platform.WinRT +{ + public class FormsSearchBox : SearchBox + { + public static readonly DependencyProperty HorizontalTextAlignmentProperty = DependencyProperty.Register( + "HorizontalTextAlignment", typeof (Windows.UI.Xaml.TextAlignment), typeof (FormsSearchBox), + new PropertyMetadata(Windows.UI.Xaml.TextAlignment.Left)); + + public Windows.UI.Xaml.TextAlignment HorizontalTextAlignment + { + get { return (Windows.UI.Xaml.TextAlignment)GetValue(HorizontalTextAlignmentProperty); } + set { SetValue(HorizontalTextAlignmentProperty, value); } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/FormsTextBoxStyle.xaml b/Xamarin.Forms.Platform.WinRT.Tablet/FormsTextBoxStyle.xaml new file mode 100644 index 00000000..3e5f5646 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Tablet/FormsTextBoxStyle.xaml @@ -0,0 +1,257 @@ +<ResourceDictionary + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:winRt="using:Xamarin.Forms.Platform.WinRT"> + + <winRt:TextAlignmentToHorizontalAlignmentConverter x:Key="AlignmentConverter" /> + <Style TargetType="winRt:FormsTextBox" x:Key="FormsTextBoxStyle"> + <!-- This is adapted from the default styling for TextBox --> + + <Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" /> + <Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" /> + <Setter Property="Foreground" Value="{ThemeResource TextBoxForegroundThemeBrush}" /> + <Setter Property="Background" Value="{ThemeResource TextBoxBackgroundThemeBrush}" /> + <Setter Property="BorderBrush" Value="{ThemeResource TextBoxBorderThemeBrush}" /> + <Setter Property="SelectionHighlightColor" Value="{ThemeResource TextSelectionHighlightColorThemeBrush}" /> + <Setter Property="BorderThickness" Value="{ThemeResource TextControlBorderThemeThickness}" /> + <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" /> + <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" /> + <Setter Property="PlaceholderForegroundBrush" Value="{ThemeResource TextBoxPlaceholderTextThemeBrush}" /> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" /> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" /> + <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" /> + <Setter Property="Padding" Value="{ThemeResource TextControlThemePadding}" /> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="winRt:FormsTextBox"> + <Grid> + <Grid.Resources> + <Style x:Name="DeleteButtonStyle" TargetType="Button"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="Button"> + <Grid> + <VisualStateManager.VisualStateGroups> + <VisualStateGroup x:Name="CommonStates"> + <VisualState x:Name="Normal" /> + <VisualState x:Name="PointerOver"> + <Storyboard> + <ObjectAnimationUsingKeyFrames + Storyboard.TargetName="BackgroundElement" + Storyboard.TargetProperty="Background"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="{ThemeResource TextBoxButtonPointerOverBackgroundThemeBrush}" /> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames + Storyboard.TargetName="BorderElement" + Storyboard.TargetProperty="BorderBrush"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="{ThemeResource TextBoxButtonPointerOverBorderThemeBrush}" /> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames + Storyboard.TargetName="GlyphElement" + Storyboard.TargetProperty="Foreground"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="{ThemeResource TextBoxButtonPointerOverForegroundThemeBrush}" /> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="Pressed"> + <Storyboard> + <ObjectAnimationUsingKeyFrames + Storyboard.TargetName="BackgroundElement" + Storyboard.TargetProperty="Background"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="{ThemeResource TextBoxButtonPressedBackgroundThemeBrush}" /> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames + Storyboard.TargetName="BorderElement" + Storyboard.TargetProperty="BorderBrush"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="{ThemeResource TextBoxButtonPressedBorderThemeBrush}" /> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames + Storyboard.TargetName="GlyphElement" + Storyboard.TargetProperty="Foreground"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="{ThemeResource TextBoxButtonPressedForegroundThemeBrush}" /> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="Disabled"> + <Storyboard> + <DoubleAnimation + Storyboard.TargetName="BackgroundElement" + Storyboard.TargetProperty="Opacity" + To="0" + Duration="0" /> + <DoubleAnimation Storyboard.TargetName="BorderElement" + Storyboard.TargetProperty="Opacity" + To="0" + Duration="0" /> + </Storyboard> + </VisualState> + </VisualStateGroup> + </VisualStateManager.VisualStateGroups> + <Border x:Name="BorderElement" + BorderBrush="{ThemeResource TextBoxButtonBorderThemeBrush}" + BorderThickness="{TemplateBinding BorderThickness}" /> + <Border x:Name="BackgroundElement" + Background="{ThemeResource TextBoxButtonBackgroundThemeBrush}" + Margin="{TemplateBinding BorderThickness}"> + <TextBlock x:Name="GlyphElement" + Foreground="{ThemeResource TextBoxButtonForegroundThemeBrush}" + VerticalAlignment="Center" + HorizontalAlignment="Center" + FontStyle="Normal" + Text="" + FontFamily="{ThemeResource SymbolThemeFontFamily}" + AutomationProperties.AccessibilityView="Raw" /> + </Border> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + </Grid.Resources> + <VisualStateManager.VisualStateGroups> + <VisualStateGroup x:Name="CommonStates"> + <VisualState x:Name="Disabled"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement" + Storyboard.TargetProperty="Background"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="{ThemeResource TextBoxDisabledBackgroundThemeBrush}" /> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" + Storyboard.TargetProperty="BorderBrush"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="{ThemeResource TextBoxDisabledBorderThemeBrush}" /> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement" + Storyboard.TargetProperty="Foreground"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="{ThemeResource TextBoxDisabledForegroundThemeBrush}" /> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames + Storyboard.TargetName="PlaceholderTextContentPresenter" + Storyboard.TargetProperty="Foreground"> + <DiscreteObjectKeyFrame KeyTime="0" + Value="{ThemeResource TextBoxDisabledForegroundThemeBrush}" /> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="Normal"> + <Storyboard> + <DoubleAnimation Storyboard.TargetName="BackgroundElement" + Storyboard.TargetProperty="Opacity" + Duration="0" + To="{ThemeResource TextControlBackgroundThemeOpacity}" /> + <DoubleAnimation Storyboard.TargetName="BorderElement" + Storyboard.TargetProperty="Opacity" + Duration="0" + To="{ThemeResource TextControlBorderThemeOpacity}" /> + </Storyboard> + </VisualState> + <VisualState x:Name="PointerOver"> + <Storyboard> + <DoubleAnimation Storyboard.TargetName="BackgroundElement" + Storyboard.TargetProperty="Opacity" + Duration="0" + To="{ThemeResource TextControlPointerOverBackgroundThemeOpacity}" /> + <DoubleAnimation Storyboard.TargetName="BorderElement" + Storyboard.TargetProperty="Opacity" + Duration="0" + To="{ThemeResource TextControlPointerOverBorderThemeOpacity}" /> + </Storyboard> + </VisualState> + <VisualState x:Name="Focused" /> + </VisualStateGroup> + <VisualStateGroup x:Name="ButtonStates"> + <VisualState x:Name="ButtonVisible"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DeleteButton" + Storyboard.TargetProperty="Visibility"> + <DiscreteObjectKeyFrame KeyTime="0"> + <DiscreteObjectKeyFrame.Value> + <Visibility>Visible</Visibility> + </DiscreteObjectKeyFrame.Value> + </DiscreteObjectKeyFrame> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="ButtonCollapsed" /> + </VisualStateGroup> + </VisualStateManager.VisualStateGroups> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="*" /> + <ColumnDefinition Width="Auto" /> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="*" /> + </Grid.RowDefinitions> + <Border x:Name="BackgroundElement" + Grid.Row="1" + Background="{TemplateBinding Background}" + Margin="{TemplateBinding BorderThickness}" + Grid.ColumnSpan="2" + Grid.RowSpan="1" /> + <Border x:Name="BorderElement" + Grid.Row="1" + BorderBrush="{TemplateBinding BorderBrush}" + BorderThickness="{TemplateBinding BorderThickness}" + Grid.ColumnSpan="2" + Grid.RowSpan="1" /> + <ContentPresenter x:Name="HeaderContentPresenter" + Grid.Row="0" + Foreground="{ThemeResource TextBoxForegroundHeaderThemeBrush}" + Margin="0,4,0,4" + Grid.ColumnSpan="2" + Content="{TemplateBinding Header}" + ContentTemplate="{TemplateBinding HeaderTemplate}" + FontWeight="Semilight" /> + <ScrollViewer x:Name="ContentElement" + Grid.Row="1" + HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}" + HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" + VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" + VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" + IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}" + IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}" + IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" + Margin="{TemplateBinding BorderThickness}" + Padding="{TemplateBinding Padding}" + IsTabStop="False" + AutomationProperties.AccessibilityView="Raw" + ZoomMode="Disabled" /> + <!-- Converting the TextAlignment set for the control's input text to a HorizontalAlignment + so the PlaceholderText's alignment will match the input text --> + <ContentControl x:Name="PlaceholderTextContentPresenter" + Grid.Row="1" + Foreground="{TemplateBinding PlaceholderForegroundBrush}" + Margin="{TemplateBinding BorderThickness}" + Padding="{TemplateBinding Padding}" + IsTabStop="False" + Grid.ColumnSpan="2" + Content="{TemplateBinding PlaceholderText}" + IsHitTestVisible="False" + HorizontalAlignment="{Binding TextAlignment, + RelativeSource={RelativeSource Mode=TemplatedParent}, + Converter={StaticResource AlignmentConverter}}" /> + <Button x:Name="DeleteButton" + Grid.Row="1" + Style="{StaticResource DeleteButtonStyle}" + BorderThickness="{TemplateBinding BorderThickness}" + IsTabStop="False" + Grid.Column="1" + Visibility="Collapsed" + FontSize="{TemplateBinding FontSize}" + VerticalAlignment="Stretch" /> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + +</ResourceDictionary>
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/Properties/AssemblyInfo.cs b/Xamarin.Forms.Platform.WinRT.Tablet/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..610ee3db --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Tablet/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +using System.Reflection; +using Xamarin.Forms; +using Xamarin.Forms.Platform.WinRT; + +[assembly: AssemblyTitle("Xamarin.Forms.Platform.WinRT.Phone")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCulture("")] +[assembly: Dependency(typeof (WindowsResourcesProvider))] +[assembly: ExportRenderer(typeof (SearchBar), typeof (SearchBarRenderer))] +[assembly: ExportRenderer(typeof (TabbedPage), typeof (TabbedPageRenderer))]
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/SearchBarRenderer.cs b/Xamarin.Forms.Platform.WinRT.Tablet/SearchBarRenderer.cs new file mode 100644 index 00000000..de713a91 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Tablet/SearchBarRenderer.cs @@ -0,0 +1,165 @@ +using System.ComponentModel; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Media; + +namespace Xamarin.Forms.Platform.WinRT +{ + public class SearchBarRenderer + : ViewRenderer<SearchBar, FormsSearchBox> + { + Brush _defaultPlaceholderColorBrush; + Brush _defaultTextColorBrush; + + bool _fontApplied; + + FormsTextBox _queryTextBox; + + protected override void OnElementChanged(ElementChangedEventArgs<SearchBar> e) + { + if (e.NewElement != null) + { + if (Control == null) + { + SetNativeControl(new FormsSearchBox()); + Control.QuerySubmitted += OnQuerySubmitted; + Control.QueryChanged += OnQueryChanged; + Control.Loaded += (sender, args) => + { + _queryTextBox = Control.GetFirstDescendant<FormsTextBox>(); + UpdateTextColor(); + UpdatePlaceholderColor(); + }; + } + + UpdateText(); + UpdatePlaceholder(); + UpdateFont(); + UpdateAlignment(); + UpdatePlaceholderColor(); + UpdateTextColor(); + } + + base.OnElementChanged(e); + } + + protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) + { + base.OnElementPropertyChanged(sender, e); + + if (e.PropertyName == SearchBar.TextProperty.PropertyName) + UpdateText(); + else if (e.PropertyName == SearchBar.PlaceholderProperty.PropertyName) + UpdatePlaceholder(); + else if (e.PropertyName == SearchBar.FontAttributesProperty.PropertyName) + UpdateFont(); + else if (e.PropertyName == SearchBar.FontFamilyProperty.PropertyName) + UpdateFont(); + else if (e.PropertyName == SearchBar.FontSizeProperty.PropertyName) + UpdateFont(); + else if (e.PropertyName == SearchBar.HorizontalTextAlignmentProperty.PropertyName) + UpdateAlignment(); + else if (e.PropertyName == SearchBar.PlaceholderColorProperty.PropertyName) + UpdatePlaceholderColor(); + else if (e.PropertyName == SearchBar.TextColorProperty.PropertyName) + UpdateTextColor(); + } + + void OnQuerySubmitted(SearchBox sender, SearchBoxQuerySubmittedEventArgs e) + { + Element.OnSearchButtonPressed(); + } + + void UpdatePlaceholder() + { + Control.PlaceholderText = Element.Placeholder ?? string.Empty; + } + + void UpdateFont() + { + if (Control == null) + return; + + var searchBar = Element; + + if (searchBar == null) + return; + + var searchBarIsDefault = searchBar.FontFamily == null && + searchBar.FontSize == Device.GetNamedSize(NamedSize.Default, typeof (SearchBar), true) && + searchBar.FontAttributes == FontAttributes.None; + + if (searchBarIsDefault && !_fontApplied) + return; + + if (searchBarIsDefault) + { + Control.ClearValue(Windows.UI.Xaml.Controls.Control.FontStyleProperty); + Control.ClearValue(Windows.UI.Xaml.Controls.Control.FontSizeProperty); + Control.ClearValue(Windows.UI.Xaml.Controls.Control.FontFamilyProperty); + Control.ClearValue(Windows.UI.Xaml.Controls.Control.FontWeightProperty); + Control.ClearValue(Windows.UI.Xaml.Controls.Control.FontStretchProperty); + } + else + Control.ApplyFont(searchBar); + + _fontApplied = true; + } + + void OnQueryChanged(SearchBox sender, SearchBoxQueryChangedEventArgs e) + { + ((IElementController)Element).SetValueFromRenderer(SearchBar.TextProperty, e.QueryText); + } + + void UpdateText() + { + Control.QueryText = Element.Text ?? string.Empty; + } + + void UpdateAlignment() + { + Control.HorizontalTextAlignment = Element.HorizontalTextAlignment.ToNativeTextAlignment(); + } + + void UpdateTextColor() + { + if (_queryTextBox == null) + return; + + var textColor = Element.TextColor; + + if (textColor.IsDefault) + { + if (_defaultTextColorBrush == null) + return; + + _queryTextBox.Foreground = _defaultTextColorBrush; + } + + if (_defaultTextColorBrush == null) + _defaultTextColorBrush = _queryTextBox.Foreground; + + _queryTextBox.Foreground = textColor.ToBrush(); + } + + void UpdatePlaceholderColor() + { + if (_queryTextBox == null) + return; + + var placeholderColor = Element.PlaceholderColor; + + if (placeholderColor.IsDefault) + { + if (_defaultPlaceholderColorBrush == null) + return; + + _queryTextBox.PlaceholderForegroundBrush = _defaultPlaceholderColorBrush; + } + + if (_defaultPlaceholderColorBrush == null) + _defaultPlaceholderColorBrush = _queryTextBox.PlaceholderForegroundBrush; + + _queryTextBox.PlaceholderForegroundBrush = placeholderColor.ToBrush(); + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs b/Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs new file mode 100644 index 00000000..33923a49 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Tablet/TabbedPageRenderer.cs @@ -0,0 +1,236 @@ +using System; +using System.Collections.Specialized; +using System.ComponentModel; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Media.Animation; + +namespace Xamarin.Forms.Platform.WinRT +{ + public class TabbedPageRenderer + : IVisualElementRenderer + { + Canvas _canvas; + + bool _disposed; + TabsControl _tabs; + VisualElementTracker<Page, Canvas> _tracker; + + public TabbedPage Page + { + get { return (TabbedPage)Element; } + } + + protected VisualElementTracker<Page, Canvas> Tracker + { + get { return _tracker; } + set + { + if (_tracker == value) + return; + + if (_tracker != null) + _tracker.Dispose(); + + _tracker = value; + } + } + + public event EventHandler<VisualElementChangedEventArgs> ElementChanged; + + public FrameworkElement ContainerElement + { + get { return _canvas; } + } + + public VisualElement Element { get; private set; } + + public void SetElement(VisualElement element) + { + if (element != null && !(element is TabbedPage)) + throw new ArgumentException("Element must be a TabbedPage", "element"); + + var oldElement = Page; + Element = element; + + if (oldElement != null) + { + oldElement.PropertyChanged -= OnElementPropertyChanged; + ((INotifyCollectionChanged)oldElement.Children).CollectionChanged -= OnPagesChanged; + } + + if (element != null) + { + if (_tracker == null) + { + _tabs = new TabsControl(); + + _canvas = new Canvas(); + + _canvas.ChildrenTransitions = new TransitionCollection + { + new EntranceThemeTransition() + }; + + Tracker = new BackgroundTracker<Canvas>(Panel.BackgroundProperty) + { + Element = (Page)element, + Control = _canvas, + Container = _canvas + }; + + _canvas.Loaded += OnLoaded; + _canvas.Unloaded += OnUnloaded; + } + + _tabs.DataContext = element; + + OnPagesChanged(Page.Children, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + UpdateCurrentPage(); + + ((INotifyCollectionChanged)Page.Children).CollectionChanged += OnPagesChanged; + element.PropertyChanged += OnElementPropertyChanged; + } + + OnElementChanged(new VisualElementChangedEventArgs(oldElement, element)); + } + + public SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint) + { + if (_canvas.Children.Count == 0) + return new SizeRequest(); + + var constraint = new Windows.Foundation.Size(widthConstraint, heightConstraint); + var child = (FrameworkElement)_canvas.Children[0]; + + var oldWidth = child.Width; + var oldHeight = child.Height; + + child.Height = double.NaN; + child.Width = double.NaN; + + child.Measure(constraint); + var result = new Size(Math.Ceiling(child.DesiredSize.Width), Math.Ceiling(child.DesiredSize.Height)); + + child.Width = oldWidth; + child.Height = oldHeight; + + return new SizeRequest(result); + } + + public void Dispose() + { + Dispose(true); + } + + protected virtual void Dispose(bool disposing) + { + if (!disposing || _disposed) + return; + + _disposed = true; + SetElement(null); + Tracker = null; + } + + protected virtual void OnElementChanged(VisualElementChangedEventArgs e) + { + var changed = ElementChanged; + if (changed != null) + changed(this, e); + } + + void OnPagesChanged(object sender, NotifyCollectionChangedEventArgs e) + { + e.Apply(Page.Children, _tabs.Items); + } + + internal void OnTabSelected(Page tab) + { + CloseTabs(); + Page.CurrentPage = tab; + } + + void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == "CurrentPage") + UpdateCurrentPage(); + } + + void UpdateCurrentPage() + { + var renderer = Page.CurrentPage.GetOrCreateRenderer(); + _canvas.Children.Clear(); + + if (renderer != null) + _canvas.Children.Add(renderer.ContainerElement); + } + + void OnLoaded(object sender, RoutedEventArgs args) + { + if (Page == null) + return; + + ShowTabs(); + Page.SendAppearing(); + } + + Windows.UI.Xaml.Controls.Page GetTopPage() + { + var frame = Window.Current.Content as Windows.UI.Xaml.Controls.Frame; + if (frame == null) + return null; + + return frame.Content as Windows.UI.Xaml.Controls.Page; + } + + AppBar GetOrCreateAppBar() + { + var npage = GetTopPage(); + if (npage == null) + return null; + + if (npage.TopAppBar == null) + npage.TopAppBar = new AppBar(); + + return npage.TopAppBar; + } + + void ShowTabs() + { + var bar = GetOrCreateAppBar(); + if (bar != null) + bar.Content = _tabs; + } + + void CloseTabs() + { + var page = GetTopPage(); + if (page == null) + return; + + if (page.TopAppBar != null) + page.TopAppBar.IsOpen = false; + } + + void RemoveTabs() + { + var page = GetTopPage(); + if (page == null) + return; + + // Explicitly unparent this.tabs so we can reuse + if (page.TopAppBar != null) + page.TopAppBar.Content = null; + + page.TopAppBar = null; + } + + void OnUnloaded(object sender, RoutedEventArgs args) + { + RemoveTabs(); + if (Page != null) + Page.SendDisappearing(); + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/TabletResources.xaml b/Xamarin.Forms.Platform.WinRT.Tablet/TabletResources.xaml new file mode 100644 index 00000000..51b9e1d7 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Tablet/TabletResources.xaml @@ -0,0 +1,939 @@ +<ResourceDictionary + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:local="using:Xamarin.Forms.Platform.WinRT"> + + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="Resources.xaml" /> + <ResourceDictionary Source="FormsTextBoxStyle.xaml" /> + </ResourceDictionary.MergedDictionaries> + + <SolidColorBrush x:Key="TabButtonPointerOverBackgroundBrush" Color="#44888888" /> + <SolidColorBrush x:Key="TabButtonBackgroundBrush" Color="#29888888" /> + + <Style x:Key="FormsListViewItem" TargetType="ListViewItem"> + <Setter Property="HorizontalContentAlignment" Value="Stretch" /> + <Setter Property="Margin" Value="0" /> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="ListViewItem"> + <local:FormsListViewItemPresenter + CheckBrush="{ThemeResource ListViewItemCheckThemeBrush}" + CheckHintBrush="{ThemeResource ListViewItemCheckHintThemeBrush}" + CheckSelectingBrush="{ThemeResource ListViewItemCheckSelectingThemeBrush}" + ContentMargin="0" + DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}" + DragBackground="{ThemeResource ListViewItemDragBackgroundThemeBrush}" + DragForeground="{ThemeResource ListViewItemDragForegroundThemeBrush}" + DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}" + FocusBorderBrush="{ThemeResource ListViewItemFocusBorderThemeBrush}" + PlaceholderBackground="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" + PointerOverBackground="{ThemeResource ListViewItemPointerOverBackgroundThemeBrush}" + PointerOverBackgroundMargin="0" + ReorderHintOffset="{ThemeResource ListViewItemReorderHintThemeOffset}" + SelectedBackground="{ThemeResource ListViewItemSelectedBackgroundThemeBrush}" + SelectedBorderThickness="{ThemeResource ListViewItemCompactSelectedBorderThemeThickness}" + SelectedForeground="{ThemeResource ListViewItemSelectedForegroundThemeBrush}" + SelectedPointerOverBackground="{ThemeResource ListViewItemSelectedPointerOverBackgroundThemeBrush}" + SelectedPointerOverBorderBrush="{ThemeResource ListViewItemSelectedPointerOverBorderThemeBrush}" + SelectionCheckMarkVisualEnabled="False" /> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <DataTemplate x:Key="TextCell"> + <StackPanel Margin="5,4,4,9.5"> + <TextBlock + Text="{Binding Text}" + Style="{ThemeResource TitleTextBlockStyle}" + Visibility="{Binding Text,RelativeSource={RelativeSource Self}, Converter={StaticResource CollapseWhenEmpty}}" + Foreground="{Binding TextColor, Converter={StaticResource ColorConverter}, ConverterParameter=DefaultTextForegroundThemeBrush}" /> + + <TextBlock + Text="{Binding Detail}" + Style="{ThemeResource BodyTextBlockStyle}" + Visibility="{Binding Text,RelativeSource={RelativeSource Self}, Converter={StaticResource CollapseWhenEmpty}}" + Foreground="{Binding DetailColor, Converter={StaticResource ColorConverter}, ConverterParameter=DefaultTextForegroundThemeBrush}" /> + </StackPanel> + </DataTemplate> + + <DataTemplate x:Key="ListViewHeaderTextCell"> + <StackPanel Margin="5,4,4,9.5"> + <TextBlock + Text="{Binding Text}" + Style="{ThemeResource SubheaderTextBlockStyle}" + Visibility="{Binding Text,RelativeSource={RelativeSource Self}, Converter={StaticResource CollapseWhenEmpty}}" + Foreground="{Binding TextColor, Converter={StaticResource ColorConverter}, ConverterParameter=DefaultTextForegroundThemeBrush}" /> + + <TextBlock + Text="{Binding Detail}" + Style="{ThemeResource BodyTextBlockStyle}" + Visibility="{Binding Text,RelativeSource={RelativeSource Self}, Converter={StaticResource CollapseWhenEmpty}}" + Foreground="{Binding DetailColor, Converter={StaticResource ColorConverter}, ConverterParameter=DefaultTextForegroundThemeBrush}" /> + </StackPanel> + </DataTemplate> + + <DataTemplate x:Key="ImageCell"> + <Grid Margin="5,4,4,9.5"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="Auto" /> + <ColumnDefinition /> + </Grid.ColumnDefinitions> + + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + </Grid.RowDefinitions> + + <Image Grid.Column="0" Grid.RowSpan="2" + DataContext="{Binding ImageSource, Converter={StaticResource ImageConverter}}" + Source="{Binding Value}" + VerticalAlignment="Center" /> + + <TextBlock Grid.Column="1" Grid.Row="0" + Text="{Binding Text}" + Style="{ThemeResource TitleTextBlockStyle}" + Visibility="{Binding Text,RelativeSource={RelativeSource Self}, Converter={StaticResource CollapseWhenEmpty}}" + Foreground="{Binding TextColor, Converter={StaticResource ColorConverter}, ConverterParameter=DefaultTextForegroundThemeBrush}" /> + + <TextBlock Grid.Column="1" Grid.Row="1" + Text="{Binding Detail}" + Style="{ThemeResource BodyTextBlockStyle}" + Visibility="{Binding Text,RelativeSource={RelativeSource Self}, Converter={StaticResource CollapseWhenEmpty}}" + Foreground="{Binding DetailColor, Converter={StaticResource ColorConverter}, ConverterParameter=DefaultTextForegroundThemeBrush}" /> + </Grid> + </DataTemplate> + + <DataTemplate x:Key="SwitchCell"> + <Grid Margin="5,4,4,9.5" HorizontalAlignment="Stretch"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="*" /> + <ColumnDefinition Width="Auto" /> + </Grid.ColumnDefinitions> + + <TextBlock Grid.Column="0" Text="{Binding Text}" VerticalAlignment="Center" Style="{ThemeResource TitleTextBlockStyle}" /> + + <ToggleSwitch Grid.Column="1" IsOn="{Binding On, Mode=TwoWay}" OnContent="" OffContent="" VerticalAlignment="Center" /> + </Grid> + </DataTemplate> + + <DataTemplate x:Key="EntryCell"> + <local:EntryCellTextBox Margin="5,4,4,9.5" IsEnabled="{Binding IsEnabled}" Header="{Binding}" Text="{Binding Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" PlaceholderText="{Binding Placeholder}" TextAlignment="{Binding HorizontalTextAlignment,Converter={StaticResource HorizontalTextAlignmentConverter}}" InputScope="{Binding Keyboard,Converter={StaticResource KeyboardConverter}}" HorizontalAlignment="Stretch"> + <local:EntryCellTextBox.HeaderTemplate> + <DataTemplate> + <TextBlock Text="{Binding Label}" Style="{ThemeResource TitleTextBlockStyle}" Foreground="{Binding LabelColor, Converter={StaticResource ColorConverter}, ConverterParameter=DefaultTextForegroundThemeBrush}" /> + </DataTemplate> + </local:EntryCellTextBox.HeaderTemplate> + </local:EntryCellTextBox> + </DataTemplate> + + <DataTemplate x:Key="ViewCell"> + <ContentControl DataContext="{Binding Cell}"> + <ContentPresenter Height="{Binding RenderHeight, Converter={StaticResource HeightConverter}}" Content="{Binding View, Converter={StaticResource ViewToRenderer}}" /> + </ContentControl> + </DataTemplate> + + <Style x:Key="JumpListGrid" TargetType="GridView"> + <Setter Property="ItemTemplate"> + <Setter.Value> + <DataTemplate> + <Border Background="{ThemeResource SystemColorControlAccentBrush}" Padding="5" Margin="3" MinHeight="80" MinWidth="80"> + <TextBlock Text="{Binding}" Style="{ThemeResource SubheaderTextBlockStyle}" VerticalAlignment="Bottom" /> + </Border> + </DataTemplate> + </Setter.Value> + </Setter> + </Style> + + <GroupStyle x:Key="ListViewGroup" HidesIfEmpty="False"> + <GroupStyle.HeaderContainerStyle> + <Style TargetType="ListViewHeaderItem"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate> + <local:ListGroupHeaderPresenter /> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + </GroupStyle.HeaderContainerStyle> + <GroupStyle.HeaderTemplate> + <DataTemplate> + <local:CellControl IsGroupHeader="true" HorizontalContentAlignment="Stretch" /> + </DataTemplate> + </GroupStyle.HeaderTemplate> + </GroupStyle> + + <Style TargetType="local:TabButton"> + <Setter Property="MinWidth" Value="166" /> + <Setter Property="Margin" Value="0,0,15,0" /> + <Setter Property="Padding" Value="9.5" /> + <Setter Property="HorizontalContentAlignment" Value="Stretch" /> + <Setter Property="VerticalAlignment" Value="Stretch" /> + <Setter Property="VerticalContentAlignment" Value="Bottom" /> + <Setter Property="Background" Value="{ThemeResource TabButtonBackgroundBrush}" /> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate> + <Border x:Name="Border" Background="{TemplateBinding Background}" BorderThickness="0" Margin="{TemplateBinding Margin}"> + <VisualStateManager.VisualStateGroups> + <VisualStateGroup x:Name="CommonStates"> + <VisualState x:Name="Normal" /> + <VisualState x:Name="Pressed"> + <Storyboard> + <PointerDownThemeAnimation TargetName="Border" /> + <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="Background"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TabButtonPointerOverBackgroundBrush}" /> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonPointerOverForegroundThemeBrush}" /> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="PointerOver"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="Background"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TabButtonPointerOverBackgroundBrush}" /> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonPointerOverForegroundThemeBrush}" /> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualStateGroup.Transitions> + <VisualTransition From="Pressed" To="Normal"> + <Storyboard> + <PointerUpThemeAnimation TargetName="Border" /> + </Storyboard> + </VisualTransition> + <VisualTransition From="Pressed" To="PointerOver"> + <Storyboard> + <PointerUpThemeAnimation TargetName="Border" /> + </Storyboard> + </VisualTransition> + </VisualStateGroup.Transitions> + </VisualStateGroup> + </VisualStateManager.VisualStateGroups> + + <ContentPresenter x:Name="ContentPresenter" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <Style TargetType="local:TabsControl"> + <Setter Property="Background" Value="{ThemeResource AppBarBackgroundThemeBrush}" /> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate> + <Border Background="{TemplateBinding Background}" BorderThickness="0"> + <Grid Margin="19,13,19,13"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="*" /> + </Grid.RowDefinitions> + + <TextBlock Grid.Row="0" Margin="9.5,0,0,9.5" Text="{Binding Title, Converter={StaticResource UpperConverter}}" + Opacity=".6" FontWeight="SemiBold" Foreground="{ThemeResource AppBarItemForegroundThemeBrush}" + Style="{ThemeResource BaseTextBlockStyle}" /> + + <ScrollViewer Grid.Row="1" VerticalScrollMode="Disabled" VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Auto"> + <ItemsPresenter /> + </ScrollViewer> + </Grid> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + <Setter Property="ItemsPanel"> + <Setter.Value> + <ItemsPanelTemplate> + <StackPanel Orientation="Horizontal" Margin="0,11,0,0" /> + </ItemsPanelTemplate> + </Setter.Value> + </Setter> + <Setter Property="ItemTemplate"> + <Setter.Value> + <DataTemplate> + <local:TabButton> + <StackPanel VerticalAlignment="Bottom"> + <Image DataContext="{Binding Icon, Converter={StaticResource ImageConverter}}" Source="{Binding Value}" HorizontalAlignment="Left" /> + <TextBlock Margin="0,15,0,15" Text="{Binding Title, Converter={StaticResource UpperConverter}}" + Style="{ThemeResource CaptionTextBlockStyle}" FontWeight="SemiBold" Foreground="{ThemeResource AppBarItemForegroundThemeBrush}" HorizontalAlignment="Left" /> + </StackPanel> + </local:TabButton> + </DataTemplate> + </Setter.Value> + </Setter> + </Style> + + <ControlTemplate x:Key="MasterDetailSplit"> + <Grid Background="{TemplateBinding Background}"> + <Grid.Resources> + <Style TargetType="local:PageControl" BasedOn="{StaticResource PageControlDefaultStyle}"> + <Setter Property="Background" Value="Transparent" /> + <Setter Property="InvisibleBackButtonCollapsed" Value="True" /> + </Style> + </Grid.Resources> + + <Grid.ColumnDefinitions> + <ColumnDefinition Width="Auto" /> + <ColumnDefinition Width="*" /> + </Grid.ColumnDefinitions> + + <Border Grid.Column="0" Margin="0" Padding="0" Background="{Binding Converter={StaticResource MasterBackgroundConverter}, RelativeSource={RelativeSource Mode=TemplatedParent}}"> + <ContentPresenter x:Name="masterPresenter" /> + </Border> + + <ContentPresenter x:Name="detailPresenter" Grid.Column="1" /> + </Grid> + </ControlTemplate> + + <ControlTemplate x:Key="MasterDetailPopup"> + <Grid Background="{TemplateBinding Background}"> + <Grid.Resources> + <Style TargetType="local:PageControl" BasedOn="{StaticResource PageControlDefaultStyle}"> + <Setter Property="Background" Value="Transparent" /> + </Style> + </Grid.Resources> + + <Popup x:Name="popup" IsLightDismissEnabled="true"> + <Popup.ChildTransitions> + <TransitionCollection> + <PaneThemeTransition Edge="Left" /> + </TransitionCollection> + </Popup.ChildTransitions> + + <Border Margin="0" Padding="0" BorderThickness="0" Background="{Binding Converter={StaticResource MasterBackgroundConverter}, RelativeSource={RelativeSource Mode=TemplatedParent}}"> + <ContentPresenter x:Name="masterPresenter" /> + </Border> + </Popup> + + <ContentPresenter x:Name="detailPresenter" /> + </Grid> + </ControlTemplate> + + <Style x:Key="PageControlDefaultStyle" TargetType="local:PageControl"> + <Setter Property="ContentMargin" Value="0" /> + <Setter Property="TitleBrush" Value="{ThemeResource DefaultTextForegroundThemeBrush}" /> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="local:PageControl"> + <Grid Background="{TemplateBinding Background}"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="*" /> + </Grid.RowDefinitions> + + <Grid Grid.Row="0" Grid.Column="0" Height="79" VerticalAlignment="Center" Background="{TemplateBinding NavigationBarBackground}" Visibility="{Binding ShowNavigationBar,RelativeSource={RelativeSource Mode=TemplatedParent},Converter={StaticResource BoolVisibilityConverter}}"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="Auto" MinWidth="{Binding TitleInset,RelativeSource={RelativeSource TemplatedParent}}" /> + <ColumnDefinition Width="*" /> + </Grid.ColumnDefinitions> + + <AppBarButton x:Name="backButton" Grid.Column="0" Margin="0,6,0,0" Foreground="{TemplateBinding TitleBrush}" ToolTipService.ToolTip="{TemplateBinding BackButtonTitle}" HorizontalAlignment="Right" VerticalAlignment="Center" Visibility="Collapsed"> + <AppBarButton.Icon> + <SymbolIcon Symbol="Back" /> + </AppBarButton.Icon> + </AppBarButton> + + <TextBlock Name="title" Padding="10,0,0,0" Grid.Column="1" Foreground="{TemplateBinding TitleBrush}" VerticalAlignment="Center" Style="{ThemeResource HeaderTextBlockStyle}" Text="{Binding Title}" /> + </Grid> + + <ContentPresenter Margin="{TemplateBinding ContentMargin}" ContentTransitions="{TemplateBinding ContentTransitions}" x:Name="presenter" Grid.Row="1" /> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <Style TargetType="local:PageControl" BasedOn="{StaticResource PageControlDefaultStyle}" /> + + <Style TargetType="local:FormsSearchBox"> + <Setter Property="Background" Value="{ThemeResource SearchBoxBackgroundThemeBrush}"/> + <Setter Property="BorderBrush" Value="{ThemeResource SearchBoxBorderThemeBrush}"/> + <Setter Property="BorderThickness" Value="{ThemeResource SearchBoxBorderThemeThickness}"/> + <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/> + <Setter Property="FontSize" Value="{ThemeResource SearchBoxContentThemeFontSize}"/> + <Setter Property="FontWeight" Value="{ThemeResource SearchBoxContentThemeFontWeight}"/> + <Setter Property="Foreground" Value="{ThemeResource SearchBoxForegroundThemeBrush}"/> + <Setter Property="Padding" Value="{ThemeResource SearchBoxThemePadding}"/> + <Setter Property="IsTabStop" Value="False"/> + <Setter Property="Typography.StylisticSet20" Value="True"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="local:FormsSearchBox"> + <Grid x:Name="SearchBoxGrid"> + <Grid.Resources> + <Style x:Key="SearchButtonStyle" TargetType="Button"> + <Setter Property="IsTabStop" Value="False"/> + <Setter Property="VerticalAlignment" Value="Stretch"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="Button"> + <Grid Background="Transparent"> + <VisualStateManager.VisualStateGroups> + <VisualStateGroup x:Name="CommonStates"> + <VisualState x:Name="Normal"/> + <VisualState x:Name="PointerOver"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="SearchGlyph"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxButtonPointerOverForegroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchButtonBackground"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxButtonPointerOverBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="Pressed"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="SearchGlyph"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxFocusedTextThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchButtonBackground"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxFocusedBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="Disabled"/> + </VisualStateGroup> + <VisualStateGroup x:Name="FocusStates"> + <VisualState x:Name="Focused"/> + <VisualState x:Name="Unfocused"/> + <VisualState x:Name="PointerFocused"/> + </VisualStateGroup> + </VisualStateManager.VisualStateGroups> + <Grid x:Name="SearchButtonBackground" Background="{TemplateBinding Background}"> + <TextBlock x:Name="SearchGlyph" AutomationProperties.AccessibilityView="Raw" Foreground="{TemplateBinding Foreground}" FontStyle="Normal" FontFamily="{ThemeResource SymbolThemeFontFamily}" HorizontalAlignment="Center" Text="" VerticalAlignment="Center"/> + </Grid> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + <Style x:Key="SearchTextBoxStyle" TargetType="local:FormsTextBox"> + <Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}"/> + <Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}"/> + <Setter Property="Foreground" Value="{ThemeResource TextBoxForegroundThemeBrush}"/> + <Setter Property="PlaceholderForegroundBrush" Value="{ThemeResource TextBoxPlaceholderTextThemeBrush}"/> + <Setter Property="Background" Value="{ThemeResource TextBoxBackgroundThemeBrush}"/> + <Setter Property="BorderBrush" Value="{ThemeResource TextBoxBorderThemeBrush}"/> + <Setter Property="SelectionHighlightColor" Value="{ThemeResource TextSelectionHighlightColorThemeBrush}"/> + <Setter Property="BorderThickness" Value="{ThemeResource TextControlBorderThemeThickness}"/> + <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/> + <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden"/> + <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False"/> + <Setter Property="Padding" Value="{ThemeResource TextControlThemePadding}"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="local:FormsTextBox"> + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="*"/> + </Grid.RowDefinitions> + <VisualStateManager.VisualStateGroups> + <VisualStateGroup x:Name="CommonStates"> + <VisualState x:Name="Disabled"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="BackgroundElement"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="BorderElement"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledBorderThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentElement"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledForegroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="PlaceholderTextContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledForegroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="Normal"> + <Storyboard> + <DoubleAnimation Duration="0" To="{ThemeResource TextControlBackgroundThemeOpacity}" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundElement"/> + <DoubleAnimation Duration="0" To="{ThemeResource TextControlBorderThemeOpacity}" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BorderElement"/> + </Storyboard> + </VisualState> + <VisualState x:Name="PointerOver"> + <Storyboard> + <DoubleAnimation Duration="0" To="{ThemeResource TextControlPointerOverBackgroundThemeOpacity}" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundElement"/> + <DoubleAnimation Duration="0" To="{ThemeResource TextControlPointerOverBorderThemeOpacity}" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BorderElement"/> + </Storyboard> + </VisualState> + <VisualState x:Name="Focused"/> + </VisualStateGroup> + <VisualStateGroup x:Name="ButtonStates"/> + </VisualStateManager.VisualStateGroups> + <Border x:Name="BackgroundElement" Background="{TemplateBinding Background}" Margin="{TemplateBinding BorderThickness}" Grid.Row="1" Grid.RowSpan="1"/> + <Border x:Name="BorderElement" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.Row="1" Grid.RowSpan="1"/> + <ContentPresenter x:Name="HeaderContentPresenter" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" Foreground="{ThemeResource TextBoxForegroundHeaderThemeBrush}" FontWeight="Semilight" Margin="0,4,0,4" Grid.Row="0"/> + <ScrollViewer x:Name="ContentElement" AutomationProperties.AccessibilityView="Raw" HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsTabStop="False" IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}" IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" Margin="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" Grid.Row="1" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" ZoomMode="Disabled"/> + <ContentControl x:Name="PlaceholderTextContentPresenter" Grid.ColumnSpan="2" Content="{TemplateBinding PlaceholderText}" Foreground="{TemplateBinding PlaceholderForegroundBrush}" IsHitTestVisible="False" IsTabStop="False" Margin="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" Grid.Row="1" + HorizontalAlignment="{Binding TextAlignment, + RelativeSource={RelativeSource Mode=TemplatedParent}, + Converter={StaticResource AlignmentConverter}}"/> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + </Grid.Resources> + <VisualStateManager.VisualStateGroups> + <VisualStateGroup x:Name="CommonStates"> + <VisualState x:Name="Normal"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchBoxGrid"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Background, RelativeSource={RelativeSource Mode=TemplatedParent}}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="SearchBoxBorder"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding BorderBrush, RelativeSource={RelativeSource Mode=TemplatedParent}}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="SearchButton"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Foreground, RelativeSource={RelativeSource Mode=TemplatedParent}}"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="PointerOver"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchBoxGrid"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxPointerOverBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="SearchBoxBorder"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxPointerOverBorderThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="SearchButton"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxPointerOverTextThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="Disabled"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchBoxGrid"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxDisabledBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="SearchBoxBorder"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxDisabledBorderThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="SearchButton"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxDisabledTextThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchTextBox"> + <DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="Focused"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchBoxGrid"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxFocusedBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="SearchBoxBorder"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxFocusedBorderThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="SearchButton"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxButtonForegroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchButton"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxButtonBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="SearchSuggestionsPopupBorder"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxFocusedBorderThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="FocusedDropDown"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchBoxGrid"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxFocusedBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="SearchBoxBorder"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxFocusedBorderThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="SearchButton"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxFocusedTextThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="SearchSuggestionsPopupBorder"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxFocusedBorderThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + </VisualStateGroup> + </VisualStateManager.VisualStateGroups> + <Border x:Name="SearchBoxBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition/> + <ColumnDefinition Width="Auto"/> + </Grid.ColumnDefinitions> + <local:FormsTextBox TextAlignment="{TemplateBinding HorizontalTextAlignment}" x:Name="SearchTextBox" BorderThickness="0" Background="Transparent" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding FontWeight}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" InputScope="Search" MinHeight="{ThemeResource SearchBoxTextBoxThemeMinHeight}" MaxLength="2048" Padding="{TemplateBinding Padding}" PlaceholderText="{TemplateBinding PlaceholderText}" Style="{StaticResource SearchTextBoxStyle}" TextWrapping="NoWrap" VerticalAlignment="Stretch"/> + <Button x:Name="SearchButton" AutomationProperties.AccessibilityView="Raw" Background="Transparent" Grid.Column="1" FontWeight="{ThemeResource SearchBoxButtonThemeFontWeight}" Style="{StaticResource SearchButtonStyle}"/> + </Grid> + </Border> + <Popup x:Name="SearchSuggestionsPopup" HorizontalAlignment="Left" VerticalAlignment="Bottom"> + <Border x:Name="SearchSuggestionsPopupBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" MinWidth="{ThemeResource SearchBoxSuggestionPopupThemeMinWidth}"> + <Border.Resources> + <Style x:Key="SearchSuggestionListViewItemStyle" TargetType="ListViewItem"> + <Setter Property="Background" Value="Transparent"/> + <Setter Property="TabNavigation" Value="Local"/> + <Setter Property="HorizontalContentAlignment" Value="Stretch"/> + <Setter Property="Margin" Value="0"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="ListViewItem"> + <Border x:Name="OuterContainer"> + <VisualStateManager.VisualStateGroups> + <VisualStateGroup x:Name="CommonStates"> + <VisualState x:Name="Normal"/> + <VisualState x:Name="PointerOver"> + <Storyboard> + <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PointerOverBorder"/> + </Storyboard> + </VisualState> + <VisualState x:Name="Pressed"> + <Storyboard> + <PointerDownThemeAnimation TargetName="ContentContainer"/> + </Storyboard> + </VisualState> + <VisualState x:Name="PointerOverPressed"> + <Storyboard> + <PointerDownThemeAnimation TargetName="ContentContainer"/> + <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PointerOverBorder"/> + </Storyboard> + </VisualState> + <VisualState x:Name="Disabled"> + <Storyboard> + <DoubleAnimation Duration="0" To="{ThemeResource ListViewItemDisabledThemeOpacity}" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ListViewItemContentPresenter"/> + </Storyboard> + </VisualState> + </VisualStateGroup> + <VisualStateGroup x:Name="FocusStates"> + <VisualState x:Name="Focused"> + <Storyboard> + <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisual"/> + </Storyboard> + </VisualState> + <VisualState x:Name="Unfocused"/> + <VisualState x:Name="PointerFocused"/> + </VisualStateGroup> + <VisualStateGroup x:Name="SelectionStates"> + <VisualState x:Name="Unselecting"/> + <VisualState x:Name="Unselected"/> + <VisualState x:Name="UnselectedPointerOver"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ListViewItemContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxButtonForegroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="UnselectedSwiping"/> + <VisualState x:Name="Selecting"/> + <VisualState x:Name="Selected"> + <Storyboard> + <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="SelectionBackground"/> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ListViewItemContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxButtonForegroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="SelectedSwiping"/> + <VisualState x:Name="SelectedUnfocused"> + <Storyboard> + <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="SelectionBackground"/> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ListViewItemContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxButtonForegroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + </VisualStateGroup> + </VisualStateManager.VisualStateGroups> + <Grid x:Name="ContentContainer"> + <Rectangle x:Name="PointerOverBorder" Fill="{ThemeResource SearchBoxButtonBackgroundThemeBrush}" IsHitTestVisible="False" Opacity="0"/> + <Rectangle x:Name="FocusVisual" IsHitTestVisible="False" Opacity="0" Stroke="{ThemeResource ListViewItemFocusBorderThemeBrush}" StrokeThickness="2"/> + <Rectangle x:Name="SelectionBackground" Fill="{ThemeResource SearchBoxButtonBackgroundThemeBrush}" Opacity="0"/> + <ContentPresenter x:Name="ListViewItemContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" FontWeight="{Binding FontWeight, ElementName=SearchTextBox}" FontSize="{Binding FontSize, ElementName=SearchTextBox}" FontFamily="{Binding FontFamily, ElementName=SearchTextBox}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> + </Grid> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + </Border.Resources> + <Grid MaxHeight="{ThemeResource SearchBoxSuggestionPopupThemeMaxHeight}"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + <RowDefinition/> + </Grid.RowDefinitions> + <Border x:Name="IMECandidateListContainer"/> + <Border x:Name="IMECandidateListSeparator" BorderBrush="{ThemeResource SearchBoxIMECandidateListSeparatorThemeBrush}" BorderThickness="{ThemeResource SearchBoxIMECandidateListSeparatorThemeThickness}" Grid.Row="1" Visibility="Collapsed"/> + <ListView x:Name="SearchSuggestionsList" Background="{ThemeResource TextBoxBackgroundThemeBrush}" IsTabStop="False" IsItemClickEnabled="true" Grid.Row="2"> + <ListView.Resources> + <DataTemplate x:Name="HitHighlightedTextBlock"> + <RichTextBlock x:Name="TextBlock" AutomationProperties.AccessibilityView="Raw" SelectionHighlightColor="{ThemeResource SearchBoxHitHighlightForegroundThemeBrush}" TextWrapping="Wrap" TextTrimming="WordEllipsis"> + <RichTextBlock.Resources> + <DataTemplate x:Name="SelectedHitHighlightedRun"> + <Run Foreground="{ThemeResource SearchBoxHitHighlightSelectedForegroundThemeBrush}"/> + </DataTemplate> + </RichTextBlock.Resources> + </RichTextBlock> + </DataTemplate> + </ListView.Resources> + <ListView.ItemTemplate> + <DataTemplate> + <Grid> + <ContentControl x:Name="QuerySuggestionTemplate" Typography.DiscretionaryLigatures="False" Margin="{ThemeResource SearchBoxQuerySuggestionThemeMargin}" Visibility="Collapsed" VerticalAlignment="Center"/> + <Grid x:Name="ResultSuggestionTemplate" Typography.DiscretionaryLigatures="False" Margin="{ThemeResource SearchBoxResultSuggestionThemeMargin}" Visibility="Collapsed"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="Auto"/> + <ColumnDefinition/> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition/> + <RowDefinition/> + </Grid.RowDefinitions> + <Image x:Name="ResultSuggestionImage" Height="{ThemeResource SearchBoxResultSuggestionImageThemeHeight}" Margin="{ThemeResource SearchBoxSuggestionSubcomponentThemeMargin}" Grid.RowSpan="2" Width="{ThemeResource SearchBoxResultSuggestionImageThemeWidth}"/> + <ContentControl x:Name="ResultSuggestionText" Grid.Column="1" VerticalAlignment="Center"/> + <ContentControl x:Name="ResultSuggestionDetailText" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center"/> + </Grid> + <Grid x:Name="SeparatorSuggestionTemplate" Typography.DiscretionaryLigatures="False" Margin="{ThemeResource SearchBoxSeparatorSuggestionThemeMargin}" Visibility="Collapsed"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="Auto"/> + <ColumnDefinition/> + </Grid.ColumnDefinitions> + <TextBlock x:Name="SeparatorSuggestionText" Margin="{ThemeResource SearchBoxSuggestionSubcomponentThemeMargin}" TextTrimming="WordEllipsis" VerticalAlignment="Center"/> + <Border BorderBrush="{ThemeResource SearchBoxSeparatorSuggestionForegroundThemeBrush}" BorderThickness="0,1,0,0" Grid.Column="1" VerticalAlignment="Center"/> + </Grid> + </Grid> + </DataTemplate> + </ListView.ItemTemplate> + <ListView.ItemContainerTransitions> + <TransitionCollection/> + </ListView.ItemContainerTransitions> + <ListView.ItemContainerStyle> + <StaticResource ResourceKey="SearchSuggestionListViewItemStyle"/> + </ListView.ItemContainerStyle> + </ListView> + </Grid> + </Border> + </Popup> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <Style TargetType="ToggleSwitch"> + <Setter Property="Foreground" Value="{ThemeResource ToggleSwitchForegroundThemeBrush}"/> + <Setter Property="HorizontalAlignment" Value="Left"/> + <Setter Property="VerticalAlignment" Value="Center"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/> + <Setter Property="FontWeight" Value="SemiBold"/> + <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/> + <Setter Property="MinWidth" Value="154"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="ToggleSwitch"> + <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"> + <VisualStateManager.VisualStateGroups> + <VisualStateGroup x:Name="CommonStates"> + <VisualState x:Name="Normal"/> + <VisualState x:Name="PointerOver"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="SwitchCurtain"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchCurtainPointerOverBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="InnerBorder"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchTrackPointerOverBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="SwitchKnob"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchThumbPointerOverBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Stroke" Storyboard.TargetName="SwitchKnob"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchThumbPointerOverBorderThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="Pressed"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="SwitchCurtain"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchCurtainPressedBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="InnerBorder"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchTrackPressedBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="SwitchKnob"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchThumbPressedBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Stroke" Storyboard.TargetName="SwitchKnob"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchThumbPressedForegroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="Disabled"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="HeaderContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchHeaderDisabledForegroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="OffContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchDisabledForegroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="OnContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchDisabledForegroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="OuterBorder"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchOuterBorderDisabledBorderThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="InnerBorder"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchTrackDisabledBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="SwitchKnob"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchThumbDisabledBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Stroke" Storyboard.TargetName="SwitchKnob"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchThumbDisabledBorderThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="SwitchCurtain"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleSwitchCurtainDisabledBackgroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + </VisualStateGroup> + <VisualStateGroup x:Name="ToggleStates"> + <VisualStateGroup.Transitions> + <VisualTransition x:Name="DraggingToOnTransition" From="Dragging" GeneratedDuration="0" To="On"> + <Storyboard> + <RepositionThemeAnimation FromHorizontalOffset="{Binding TemplateSettings.KnobCurrentToOnOffset, RelativeSource={RelativeSource Mode=TemplatedParent}}" TargetName="SwitchKnob"/> + <RepositionThemeAnimation FromHorizontalOffset="{Binding TemplateSettings.CurtainCurrentToOnOffset, RelativeSource={RelativeSource Mode=TemplatedParent}}" TargetName="SwitchCurtain"/> + </Storyboard> + </VisualTransition> + <VisualTransition x:Name="DraggingToOffTransition" From="Dragging" GeneratedDuration="0" To="Off"> + <Storyboard> + <RepositionThemeAnimation FromHorizontalOffset="{Binding TemplateSettings.KnobCurrentToOffOffset, RelativeSource={RelativeSource Mode=TemplatedParent}}" TargetName="SwitchKnob"/> + <RepositionThemeAnimation FromHorizontalOffset="{Binding TemplateSettings.CurtainCurrentToOffOffset, RelativeSource={RelativeSource Mode=TemplatedParent}}" TargetName="SwitchCurtain"/> + </Storyboard> + </VisualTransition> + <VisualTransition x:Name="OnToOffTransition" From="On" GeneratedDuration="0" To="Off"> + <Storyboard> + <RepositionThemeAnimation FromHorizontalOffset="{Binding TemplateSettings.KnobOnToOffOffset, RelativeSource={RelativeSource Mode=TemplatedParent}}" TargetName="SwitchKnob"/> + <RepositionThemeAnimation FromHorizontalOffset="{Binding TemplateSettings.CurtainOnToOffOffset, RelativeSource={RelativeSource Mode=TemplatedParent}}" TargetName="SwitchCurtain"/> + </Storyboard> + </VisualTransition> + <VisualTransition x:Name="OffToOnTransition" From="Off" GeneratedDuration="0" To="On"> + <Storyboard> + <RepositionThemeAnimation FromHorizontalOffset="{Binding TemplateSettings.KnobOffToOnOffset, RelativeSource={RelativeSource Mode=TemplatedParent}}" TargetName="SwitchKnob"/> + <RepositionThemeAnimation FromHorizontalOffset="{Binding TemplateSettings.CurtainOffToOnOffset, RelativeSource={RelativeSource Mode=TemplatedParent}}" TargetName="SwitchCurtain"/> + </Storyboard> + </VisualTransition> + </VisualStateGroup.Transitions> + <VisualState x:Name="Dragging"/> + <VisualState x:Name="Off"> + <Storyboard> + <DoubleAnimation Duration="0" To="-44" Storyboard.TargetProperty="X" Storyboard.TargetName="CurtainTranslateTransform"/> + </Storyboard> + </VisualState> + <VisualState x:Name="On"> + <Storyboard> + <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="X" Storyboard.TargetName="CurtainTranslateTransform"/> + <DoubleAnimation Duration="0" To="38" Storyboard.TargetProperty="X" Storyboard.TargetName="KnobTranslateTransform"/> + </Storyboard> + </VisualState> + </VisualStateGroup> + <VisualStateGroup x:Name="ContentStates"> + <VisualState x:Name="OffContent"> + <Storyboard> + <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="OffContentPresenter"/> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsHitTestVisible" Storyboard.TargetName="OffContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0"> + <DiscreteObjectKeyFrame.Value> + <x:Boolean>True</x:Boolean> + </DiscreteObjectKeyFrame.Value> + </DiscreteObjectKeyFrame> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="OnContent"> + <Storyboard> + <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="OnContentPresenter"/> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsHitTestVisible" Storyboard.TargetName="OnContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0"> + <DiscreteObjectKeyFrame.Value> + <x:Boolean>True</x:Boolean> + </DiscreteObjectKeyFrame.Value> + </DiscreteObjectKeyFrame> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + </VisualStateGroup> + <VisualStateGroup x:Name="FocusStates"> + <VisualState x:Name="Focused"> + <Storyboard> + <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualWhite"/> + <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualBlack"/> + </Storyboard> + </VisualState> + <VisualState x:Name="Unfocused"/> + <VisualState x:Name="PointerFocused"/> + </VisualStateGroup> + </VisualStateManager.VisualStateGroups> + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + </Grid.RowDefinitions> + <ContentPresenter x:Name="HeaderContentPresenter" AutomationProperties.AccessibilityView="Raw" Grid.ColumnSpan="2" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" Foreground="{ThemeResource ToggleSwitchHeaderForegroundThemeBrush}" FontWeight="Semilight" Margin="6"/> + <Grid Margin="{TemplateBinding Padding}" Grid.Row="1"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="Auto"/> + <ColumnDefinition Width="7"/> + <ColumnDefinition Width="Auto"/> + </Grid.ColumnDefinitions> + <ContentPresenter x:Name="OffContentPresenter" AutomationProperties.AccessibilityView="Raw" ContentTemplate="{TemplateBinding OffContentTemplate}" Content="{TemplateBinding OffContent}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="False" Margin="6,5,0,16" MinWidth="65" Opacity="0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> + <ContentPresenter x:Name="OnContentPresenter" AutomationProperties.AccessibilityView="Raw" ContentTemplate="{TemplateBinding OnContentTemplate}" Content="{TemplateBinding OnContent}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="False" Margin="6,5,0,16" MinWidth="65" Opacity="0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> + <Grid Background="Transparent" Grid.Column="2" ManipulationMode="None"> + <Grid x:Name="SwitchKnobBounds" Height="19" Margin="13,5,13,16"> + <Border x:Name="OuterBorder" BorderBrush="{ThemeResource ToggleSwitchOuterBorderBorderThemeBrush}" BorderThickness="2"> + <Border x:Name="InnerBorder" BorderBrush="{ThemeResource ToggleSwitchTrackBorderThemeBrush}" BorderThickness="1" Background="{ThemeResource ToggleSwitchTrackBackgroundThemeBrush}"> + <ContentPresenter x:Name="SwitchCurtainBounds"> + <ContentPresenter x:Name="SwitchCurtainClip"> + <Rectangle x:Name="SwitchCurtain" Fill="{ThemeResource ToggleSwitchCurtainBackgroundThemeBrush}" Width="44"> + <Rectangle.RenderTransform> + <TranslateTransform x:Name="CurtainTranslateTransform" X="-44"/> + </Rectangle.RenderTransform> + </Rectangle> + </ContentPresenter> + </ContentPresenter> + </Border> + </Border> + <Rectangle x:Name="SwitchKnob" Fill="{ThemeResource ToggleSwitchThumbBackgroundThemeBrush}" HorizontalAlignment="Left" Stroke="{ThemeResource ToggleSwitchThumbBorderThemeBrush}" StrokeThickness="1" Width="12"> + <Rectangle.RenderTransform> + <TranslateTransform x:Name="KnobTranslateTransform"/> + </Rectangle.RenderTransform> + </Rectangle> + <Rectangle x:Name="FocusVisualWhite" Margin="-3" Opacity="0" StrokeDashOffset="1.5" StrokeEndLineCap="Square" Stroke="{ThemeResource FocusVisualWhiteStrokeThemeBrush}" StrokeDashArray="1,1"/> + <Rectangle x:Name="FocusVisualBlack" Margin="-3" Opacity="0" StrokeDashOffset="0.5" StrokeEndLineCap="Square" Stroke="{ThemeResource FocusVisualBlackStrokeThemeBrush}" StrokeDashArray="1,1"/> + </Grid> + <Thumb x:Name="SwitchThumb" AutomationProperties.AccessibilityView="Raw"> + <Thumb.Template> + <ControlTemplate TargetType="Thumb"> + <Rectangle Fill="Transparent"/> + </ControlTemplate> + </Thumb.Template> + </Thumb> + </Grid> + </Grid> + </Grid> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + +</ResourceDictionary> + diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/TabsControl.cs b/Xamarin.Forms.Platform.WinRT.Tablet/TabsControl.cs new file mode 100644 index 00000000..d98a27a0 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Tablet/TabsControl.cs @@ -0,0 +1,50 @@ +using System; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace Xamarin.Forms.Platform.WinRT +{ + public class TabSelectedEventArgs + : EventArgs + { + public TabSelectedEventArgs(Page tab) + { + if (tab == null) + throw new ArgumentNullException("tab"); + + Tab = tab; + } + + public Page Tab { get; private set; } + } + + public class TabButton + : Windows.UI.Xaml.Controls.Button + { + protected override void OnApplyTemplate() + { + base.OnApplyTemplate(); + Click += OnClick; + } + + void OnClick(object sender, RoutedEventArgs routedEventArgs) + { + var page = DataContext as Page; + if (page == null) + return; + + var parent = page.RealParent as TabbedPage; + if (parent == null) + return; + + var renderer = Platform.GetRenderer(parent) as TabbedPageRenderer; + if (renderer != null) + renderer.OnTabSelected(page); + } + } + + public class TabsControl + : ItemsControl + { + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/WindowsPage.cs b/Xamarin.Forms.Platform.WinRT.Tablet/WindowsPage.cs new file mode 100644 index 00000000..ba5cec09 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Tablet/WindowsPage.cs @@ -0,0 +1,17 @@ + +#if WINDOWS_UWP + +namespace Xamarin.Forms.Platform.UWP +#else + +namespace Xamarin.Forms.Platform.WinRT +#endif +{ + public class WindowsPage : WindowsBasePage + { + protected override Platform CreatePlatform() + { + return new WindowsPlatform(this); + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/WindowsPlatform.cs b/Xamarin.Forms.Platform.WinRT.Tablet/WindowsPlatform.cs new file mode 100644 index 00000000..ce7e5fd7 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Tablet/WindowsPlatform.cs @@ -0,0 +1,16 @@ + +#if WINDOWS_UWP + +namespace Xamarin.Forms.Platform.UWP +#else + +namespace Xamarin.Forms.Platform.WinRT +#endif +{ + internal sealed class WindowsPlatform : Platform + { + public WindowsPlatform(Windows.UI.Xaml.Controls.Page page) : base(page) + { + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/WindowsPlatformServices.cs b/Xamarin.Forms.Platform.WinRT.Tablet/WindowsPlatformServices.cs new file mode 100644 index 00000000..d729713d --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Tablet/WindowsPlatformServices.cs @@ -0,0 +1,17 @@ +using Windows.UI.Core; + +#if WINDOWS_UWP + +namespace Xamarin.Forms.Platform.UWP +#else + +namespace Xamarin.Forms.Platform.WinRT +#endif +{ + internal class WindowsPlatformServices : WindowsBasePlatformServices + { + public WindowsPlatformServices(CoreDispatcher dispatcher) : base(dispatcher) + { + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/WindowsResourcesProvider.cs b/Xamarin.Forms.Platform.WinRT.Tablet/WindowsResourcesProvider.cs new file mode 100644 index 00000000..9c1351b0 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Tablet/WindowsResourcesProvider.cs @@ -0,0 +1,82 @@ +using System; +using Windows.UI.Text; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +#if WINDOWS_UWP + +namespace Xamarin.Forms.Platform.UWP +#else + +namespace Xamarin.Forms.Platform.WinRT +#endif +{ + internal sealed class WindowsResourcesProvider : ISystemResourcesProvider + { + public IResourceDictionary GetSystemResources() + { + Windows.UI.Xaml.ResourceDictionary windowsResources = Windows.UI.Xaml.Application.Current.Resources; + + var resources = new ResourceDictionary(); + resources[Device.Styles.TitleStyleKey] = GetStyle("HeaderTextBlockStyle"); + resources[Device.Styles.SubtitleStyleKey] = GetStyle("SubheaderTextBlockStyle"); + resources[Device.Styles.BodyStyleKey] = GetStyle("BodyTextBlockStyle"); + resources[Device.Styles.CaptionStyleKey] = GetStyle("CaptionTextBlockStyle"); +#if WINDOWS_UWP + resources[Device.Styles.ListItemTextStyleKey] = GetStyle("BaseTextBlockStyle"); +#else + resources[Device.Styles.ListItemTextStyleKey] = GetStyle("TitleTextBlockStyle"); +#endif + resources[Device.Styles.ListItemDetailTextStyleKey] = GetStyle("BodyTextBlockStyle"); + return resources; + } + + Style GetStyle(object nativeKey) + { + var style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources[nativeKey]; + + var formsStyle = new Style(typeof(Label)); + foreach (SetterBase b in style.Setters) + { + var setter = b as Windows.UI.Xaml.Setter; + if (setter == null) + continue; + + // TODO: Need to implement a stealth pass-through for things we don't support + + if (setter.Property == TextBlock.FontSizeProperty) + formsStyle.Setters.Add(Label.FontSizeProperty, setter.Value); + else if (setter.Property == TextBlock.FontFamilyProperty) + formsStyle.Setters.Add(Label.FontFamilyProperty, setter.Value); + else if (setter.Property == TextBlock.FontWeightProperty) + formsStyle.Setters.Add(Label.FontAttributesProperty, ToAttributes(Convert.ToUInt16(setter.Value))); + else if (setter.Property == TextBlock.TextWrappingProperty) + formsStyle.Setters.Add(Label.LineBreakModeProperty, ToLineBreakMode((TextWrapping)setter.Value)); + } + + return formsStyle; + } + + static FontAttributes ToAttributes(ushort uweight) + { + if (uweight == FontWeights.Bold.Weight || uweight == FontWeights.SemiBold.Weight || uweight == FontWeights.ExtraBold.Weight) + return FontAttributes.Bold; + + return FontAttributes.None; + } + + static LineBreakMode ToLineBreakMode(TextWrapping value) + { + switch (value) + { + case TextWrapping.Wrap: + return LineBreakMode.CharacterWrap; + case TextWrapping.WrapWholeWords: + return LineBreakMode.WordWrap; + default: + case TextWrapping.NoWrap: + return LineBreakMode.NoWrap; + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/Xamarin.Forms.Platform.WinRT.Tablet.csproj b/Xamarin.Forms.Platform.WinRT.Tablet/Xamarin.Forms.Platform.WinRT.Tablet.csproj new file mode 100644 index 00000000..22c153f9 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Tablet/Xamarin.Forms.Platform.WinRT.Tablet.csproj @@ -0,0 +1,157 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.30703</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{D3F9265A-30AC-43E8-A3EB-59BB76D2D0BF}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Xamarin.Forms.Platform.WinRT</RootNamespace> + <AssemblyName>Xamarin.Forms.Platform.WinRT.Tablet</AssemblyName> + <DefaultLanguage>en-US</DefaultLanguage> + <TargetPlatformVersion>8.1</TargetPlatformVersion> + <MinimumVisualStudioVersion>12</MinimumVisualStudioVersion> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_APP</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE;NETFX_CORE;WINDOWS_APP</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\ARM\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_APP</DefineConstants> + <NoWarn>;2008</NoWarn> + <DebugType>full</DebugType> + <PlatformTarget>ARM</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + <ErrorReport>prompt</ErrorReport> + <Prefer32Bit>true</Prefer32Bit> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'"> + <OutputPath>bin\ARM\Release\</OutputPath> + <DefineConstants>TRACE;NETFX_CORE;WINDOWS_APP</DefineConstants> + <Optimize>true</Optimize> + <NoWarn>;2008</NoWarn> + <DebugType>pdbonly</DebugType> + <PlatformTarget>ARM</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + <ErrorReport>prompt</ErrorReport> + <Prefer32Bit>true</Prefer32Bit> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\x64\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_APP</DefineConstants> + <NoWarn>;2008</NoWarn> + <DebugType>full</DebugType> + <PlatformTarget>x64</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + <ErrorReport>prompt</ErrorReport> + <Prefer32Bit>true</Prefer32Bit> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> + <OutputPath>bin\x64\Release\</OutputPath> + <DefineConstants>TRACE;NETFX_CORE;WINDOWS_APP</DefineConstants> + <Optimize>true</Optimize> + <NoWarn>;2008</NoWarn> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x64</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + <ErrorReport>prompt</ErrorReport> + <Prefer32Bit>true</Prefer32Bit> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\x86\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_APP</DefineConstants> + <NoWarn>;2008</NoWarn> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + <ErrorReport>prompt</ErrorReport> + <Prefer32Bit>true</Prefer32Bit> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> + <OutputPath>bin\x86\Release\</OutputPath> + <DefineConstants>TRACE;NETFX_CORE;WINDOWS_APP</DefineConstants> + <Optimize>true</Optimize> + <NoWarn>;2008</NoWarn> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x86</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + <ErrorReport>prompt</ErrorReport> + <Prefer32Bit>true</Prefer32Bit> + </PropertyGroup> + <ItemGroup> + <!-- A reference to the entire .Net Framework and Windows SDK are automatically included --> + <ProjectReference Include="..\Xamarin.Forms.Core\Xamarin.Forms.Core.csproj"> + <Project>{57b8b73d-c3b5-4c42-869e-7b2f17d354ac}</Project> + <Name>Xamarin.Forms.Core</Name> + </ProjectReference> + <ProjectReference Include="..\Xamarin.Forms.Platform.WinRT\Xamarin.Forms.Platform.WinRT.csproj"> + <Project>{f3fdd7ac-8899-4e41-bfd7-ec83403e736d}</Project> + <Name>Xamarin.Forms.Platform.WinRT</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <Compile Include="..\Xamarin.Forms.Core\Properties\GlobalAssemblyInfo.cs"> + <Link>Properties\GlobalAssemblyInfo.cs</Link> + </Compile> + <Compile Include="Forms.cs" /> + <Compile Include="FormsListViewItemPresenter.cs" /> + <Compile Include="FormsSearchBox.cs" /> + <Compile Include="SearchBarRenderer.cs" /> + <Compile Include="TabbedPageRenderer.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="TabsControl.cs" /> + <Compile Include="WindowsPlatform.cs" /> + <Compile Include="WindowsPage.cs" /> + <Compile Include="WindowsPlatformServices.cs" /> + <Compile Include="WindowsResourcesProvider.cs" /> + </ItemGroup> + <ItemGroup> + <Page Include="..\Xamarin.Forms.Platform.WinRT\Resources.xaml"> + <Link>Resources.xaml</Link> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="FormsTextBoxStyle.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="TabletResources.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Page> + </ItemGroup> + <PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '12.0' "> + <VisualStudioVersion>12.0</VisualStudioVersion> + </PropertyGroup> + <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project>
\ No newline at end of file |