summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT/EditorRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT/EditorRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.WinRT/EditorRenderer.cs29
1 files changed, 25 insertions, 4 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/EditorRenderer.cs b/Xamarin.Forms.Platform.WinRT/EditorRenderer.cs
index 7c4acfba..2fc01330 100644
--- a/Xamarin.Forms.Platform.WinRT/EditorRenderer.cs
+++ b/Xamarin.Forms.Platform.WinRT/EditorRenderer.cs
@@ -1,6 +1,7 @@
using System.ComponentModel;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Media;
#if WINDOWS_UWP
@@ -10,9 +11,10 @@ namespace Xamarin.Forms.Platform.UWP
namespace Xamarin.Forms.Platform.WinRT
#endif
{
- public class EditorRenderer : ViewRenderer<Editor, TextBox>
+ public class EditorRenderer : ViewRenderer<Editor, FormsTextBox>
{
bool _fontApplied;
+ Brush _backgroundColorFocusedDefaultBrush;
protected override void OnElementChanged(ElementChangedEventArgs<Editor> e)
{
@@ -20,7 +22,12 @@ namespace Xamarin.Forms.Platform.WinRT
{
if (Control == null)
{
- var textBox = new TextBox { AcceptsReturn = true, TextWrapping = TextWrapping.Wrap };
+ var textBox = new FormsTextBox
+ {
+ AcceptsReturn = true,
+ TextWrapping = TextWrapping.Wrap,
+ Style = Windows.UI.Xaml.Application.Current.Resources["FormsTextBoxStyle"] as Windows.UI.Xaml.Style
+ };
SetNativeControl(textBox);
@@ -50,6 +57,8 @@ namespace Xamarin.Forms.Platform.WinRT
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
+ base.OnElementPropertyChanged(sender, e);
+
if (e.PropertyName == Editor.TextColorProperty.PropertyName)
{
UpdateTextColor();
@@ -70,8 +79,6 @@ namespace Xamarin.Forms.Platform.WinRT
{
UpdateText();
}
-
- base.OnElementPropertyChanged(sender, e);
}
void OnLostFocus(object sender, RoutedEventArgs e)
@@ -79,6 +86,20 @@ namespace Xamarin.Forms.Platform.WinRT
Element.SendCompleted();
}
+ protected override void UpdateBackgroundColor()
+ {
+ base.UpdateBackgroundColor();
+
+ if (Control == null)
+ {
+ return;
+ }
+
+ // By default some platforms have alternate default background colors when focused
+ BrushHelpers.UpdateColor(Element.BackgroundColor, ref _backgroundColorFocusedDefaultBrush,
+ () => Control.BackgroundFocusBrush, brush => Control.BackgroundFocusBrush = brush);
+ }
+
void OnNativeTextChanged(object sender, Windows.UI.Xaml.Controls.TextChangedEventArgs args)
{
Element.SetValueCore(Editor.TextProperty, Control.Text);