summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xamarin.Forms.Platform.UAP/FormsTextBoxStyle.xaml2
-rw-r--r--Xamarin.Forms.Platform.WinRT/FormsTextBox.cs40
2 files changed, 33 insertions, 9 deletions
diff --git a/Xamarin.Forms.Platform.UAP/FormsTextBoxStyle.xaml b/Xamarin.Forms.Platform.UAP/FormsTextBoxStyle.xaml
index 0e147d7..0003a81 100644
--- a/Xamarin.Forms.Platform.UAP/FormsTextBoxStyle.xaml
+++ b/Xamarin.Forms.Platform.UAP/FormsTextBoxStyle.xaml
@@ -178,7 +178,7 @@
Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}" FontWeight="Normal"
Margin="0,0,0,8" Grid.Row="0" Visibility="Collapsed" x:DeferLoadStrategy="Lazy" />
<ScrollViewer x:Name="ContentElement" AutomationProperties.AccessibilityView="Raw"
- Foreground="{TemplateBinding ForegroundFocusBrush}"
+
HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
IsTabStop="False" IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
diff --git a/Xamarin.Forms.Platform.WinRT/FormsTextBox.cs b/Xamarin.Forms.Platform.WinRT/FormsTextBox.cs
index 4301dd0..03d189c 100644
--- a/Xamarin.Forms.Platform.WinRT/FormsTextBox.cs
+++ b/Xamarin.Forms.Platform.WinRT/FormsTextBox.cs
@@ -24,19 +24,27 @@ namespace Xamarin.Forms.Platform.WinRT
{
const char ObfuscationCharacter = '‚óŹ';
- public static readonly DependencyProperty PlaceholderForegroundBrushProperty = DependencyProperty.Register(nameof(PlaceholderForegroundBrush), typeof(Brush), typeof(FormsTextBox),
- new PropertyMetadata(default(Brush)));
+ public static readonly DependencyProperty PlaceholderForegroundBrushProperty =
+ DependencyProperty.Register(nameof(PlaceholderForegroundBrush), typeof(Brush), typeof(FormsTextBox),
+ new PropertyMetadata(default(Brush), FocusPropertyChanged));
- public static readonly DependencyProperty PlaceholderForegroundFocusBrushProperty = DependencyProperty.Register(nameof(PlaceholderForegroundFocusBrush), typeof(Brush), typeof(FormsTextBox),
- new PropertyMetadata(default(Brush)));
+ public static readonly DependencyProperty PlaceholderForegroundFocusBrushProperty =
+ DependencyProperty.Register(nameof(PlaceholderForegroundFocusBrush), typeof(Brush), typeof(FormsTextBox),
+ new PropertyMetadata(default(Brush), FocusPropertyChanged));
- public static readonly DependencyProperty ForegroundFocusBrushProperty = DependencyProperty.Register(nameof(ForegroundFocusBrush), typeof(Brush), typeof(FormsTextBox), new PropertyMetadata(default(Brush)));
+ public static readonly DependencyProperty ForegroundFocusBrushProperty =
+ DependencyProperty.Register(nameof(ForegroundFocusBrush), typeof(Brush), typeof(FormsTextBox),
+ new PropertyMetadata(default(Brush), FocusPropertyChanged));
- public static readonly DependencyProperty BackgroundFocusBrushProperty = DependencyProperty.Register(nameof(BackgroundFocusBrush), typeof(Brush), typeof(FormsTextBox), new PropertyMetadata(default(Brush)));
+ public static readonly DependencyProperty BackgroundFocusBrushProperty =
+ DependencyProperty.Register(nameof(BackgroundFocusBrush), typeof(Brush), typeof(FormsTextBox),
+ new PropertyMetadata(default(Brush), FocusPropertyChanged));
- public static readonly DependencyProperty IsPasswordProperty = DependencyProperty.Register(nameof(IsPassword), typeof(bool), typeof(FormsTextBox), new PropertyMetadata(default(bool), OnIsPasswordChanged));
+ public static readonly DependencyProperty IsPasswordProperty = DependencyProperty.Register(nameof(IsPassword),
+ typeof(bool), typeof(FormsTextBox), new PropertyMetadata(default(bool), OnIsPasswordChanged));
- public new static readonly DependencyProperty TextProperty = DependencyProperty.Register(nameof(Text), typeof(string), typeof(FormsTextBox), new PropertyMetadata("", TextPropertyChanged));
+ public new static readonly DependencyProperty TextProperty = DependencyProperty.Register(nameof(Text),
+ typeof(string), typeof(FormsTextBox), new PropertyMetadata("", TextPropertyChanged));
InputScope passwordInputScope;
Border _borderElement;
@@ -374,5 +382,21 @@ namespace Xamarin.Forms.Platform.WinRT
IsTextPredictionEnabled = _cachedPredictionsSetting;
}
}
+
+ static void FocusPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
+ {
+ // If we're modifying the properties related to the focus state of the control (e.g.,
+ // ForegroundFocusBrush), the changes won't be reflected immediately because they are only applied
+ // when the Windows.UI.XAML.VisualStateManager moves to the "Focused" state. So we have to force a
+ // "refresh" of the Focused state by going to that state again
+
+ var control = dependencyObject as Control;
+ if (control == null || control.FocusState == FocusState.Unfocused)
+ {
+ return;
+ }
+
+ VisualStateManager.GoToState(control, "Focused", false);
+ }
}
} \ No newline at end of file