private System.Windows.Controls.ControlTemplate GetTemplate() { string controlTemplateXaml = @"<ControlTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:phone=""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"" xmlns:Primitives=""clr-namespace:Microsoft.Phone.Controls.Primitives;assembly=Microsoft.Phone"" TargetType=""phone:Pivot""> <Grid> <Grid.RowDefinitions> <RowDefinition Height=""Auto""/> <RowDefinition Height=""Auto""/> <RowDefinition Height=""*""/> </Grid.RowDefinitions> <Grid Background=""{TemplateBinding Background}"" Grid.RowSpan=""3""/> <Grid Background=""" + RendererUtil.FromXamarinColorToWindowsBrush(BaseApp.PAGE_HEADER_COLOR).Color.ToString() + @"""> <ContentControl x:Name=""TitleElement"" ContentTemplate=""{TemplateBinding TitleTemplate}"" Content=""{TemplateBinding Title}"" Margin=""0,0,0,14""/> </Grid> <Primitives:PivotHeadersControl x:Name=""HeadersListElement"" Grid.Row=""1"" Margin=""0,10,0,5""/> <ItemsPresenter x:Name=""PivotItemPresenter"" Grid.Row=""2""/> </Grid> </ControlTemplate>"; return(XamlReader.Load(controlTemplateXaml) as System.Windows.Controls.ControlTemplate); }
/// <summary> /// Override colors of a disabled date picker /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void native_IsEnabledChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e) { Microsoft.Phone.Controls.DatePicker native = sender as Microsoft.Phone.Controls.DatePicker; if (native != null && !native.IsEnabled) { native.Foreground = RendererUtil.FromXamarinColorToWindowsBrush(BaseApp.TEXT_COLOR_DISABLED); native.BorderBrush = RendererUtil.FromXamarinColorToWindowsBrush(BaseApp.CONTROL_BORDER_COLOR_DISABLED); } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Picker> e) { base.OnElementChanged(e); if (e.OldElement == null) { var native = (ListPicker)((System.Windows.Controls.Grid)Control).Children[0]; native.HeaderTemplate = GetStyledHeaderTemplate(native.FullModeHeader as string); native.FontSize = 20; native.Margin = new System.Windows.Thickness(12, 2, 3, 8); native.Padding = new System.Windows.Thickness(0); native.BorderThickness = new System.Windows.Thickness(1); native.IsEnabledChanged += native_IsEnabledChanged; //Override default colors of Windows theme for an active picker native.Foreground = RendererUtil.FromXamarinColorToWindowsBrush(BaseApp.TEXT_COLOR); native.BorderBrush = RendererUtil.FromXamarinColorToWindowsBrush(BaseApp.CONTROL_BORDER_COLOR); } }
protected override void OnElementChanged(ElementChangedEventArgs <TimePicker> e) { base.OnElementChanged(e); if (e.OldElement == null) { var native = (Microsoft.Phone.Controls.TimePicker)Control; // Set TextColor and Border native.FontSize = 20; native.HeaderTemplate = GetStyledHeaderTemplate(native.Header as string); native.Margin = new System.Windows.Thickness(1); native.Padding = new System.Windows.Thickness(0); native.BorderThickness = new System.Windows.Thickness(1); //Override default colors of Windows theme for an active date picker native.Foreground = RendererUtil.FromXamarinColorToWindowsBrush(BaseApp.TEXT_COLOR); native.BorderBrush = RendererUtil.FromXamarinColorToWindowsBrush(BaseApp.CONTROL_BORDER_COLOR); native.IsEnabledChanged += native_IsEnabledChanged; } }
protected override void OnElementChanged(ElementChangedEventArgs <Editor> e) { base.OnElementChanged(e); if (e.OldElement == null) { var native = (TextBox)Control; // Set Border and AcceptReturn native.Margin = new System.Windows.Thickness(1, 1, 8, 5); native.Padding = new System.Windows.Thickness(5, 2, 5, 5); native.FontSize = 20; native.BorderThickness = new System.Windows.Thickness(1); native.MinHeight = 150; native.AcceptsReturn = true; native.VerticalScrollBarVisibility = ScrollBarVisibility.Visible; native.IsEnabledChanged += native_IsEnabledChanged; native.Foreground = RendererUtil.FromXamarinColorToWindowsBrush(BaseApp.TEXT_COLOR); native.BorderBrush = RendererUtil.FromXamarinColorToWindowsBrush(BaseApp.CONTROL_BORDER_COLOR); } }
/// <summary> /// Custom Renderer class /// </summary> /// <param name="e"></param> protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (e.OldElement == null) { PhoneTextBox native = Control; Control.Margin = new System.Windows.Thickness(0, -3, 0, -3); if (native != null) { // Set border, border color and put cursor at the beginning. native.Margin = new System.Windows.Thickness(2, 1, 2, 2); native.Padding = new System.Windows.Thickness(6, 5, 6, 10); native.FontSize = 20; native.BorderThickness = new System.Windows.Thickness(1); //Set colors native.Foreground = RendererUtil.FromXamarinColorToWindowsBrush(BaseApp.TEXT_COLOR); native.BorderBrush = RendererUtil.FromXamarinColorToWindowsBrush(BaseApp.CONTROL_BORDER_COLOR); } } }