fixes #8148
This commit is contained in:
melimion 2019-10-24 21:24:51 +03:00 коммит произвёл Samantha Houts
Родитель f8171b4ad4
Коммит 545ce131db
3 изменённых файлов: 30 добавлений и 10 удалений

Просмотреть файл

@ -0,0 +1,22 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 8148, "WPF Entry initial TextColor ignored when typing", PlatformAffected.WPF)]
public class Issue8148 : TestContentPage
{
protected override void Init()
{
Content = new StackLayout()
{
Children =
{
new Label() { Text = "Start typing - text should be red immediately as you typing" },
new Entry { TextColor = Color.Red },
}
};
}
}
}

Просмотреть файл

@ -36,6 +36,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue6945.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue7313.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue5500.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue8148.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue8008.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue6640.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue7556.cs" />

Просмотреть файл

@ -144,17 +144,14 @@ namespace Xamarin.Forms.Platform.WPF
Entry entry = Element;
if (entry != null)
{
if (!IsNullOrEmpty(entry.Text))
{
if (!entry.TextColor.IsDefault)
Control.Foreground = entry.TextColor.ToBrush();
else
Control.Foreground = (Brush)WControl.ForegroundProperty.GetMetadata(typeof(FormsTextBox)).DefaultValue;
if (!entry.TextColor.IsDefault)
Control.Foreground = entry.TextColor.ToBrush();
else
Control.Foreground = (Brush)WControl.ForegroundProperty.GetMetadata(typeof(FormsTextBox)).DefaultValue;
// Force the PhoneTextBox control to do some internal bookkeeping
// so the colors change immediately and remain changed when the control gets focus
Control.OnApplyTemplate();
}
// Force the PhoneTextBox control to do some internal bookkeeping
// so the colors change immediately and remain changed when the control gets focus
Control.OnApplyTemplate();
}
else
Control.Foreground = (Brush)WControl.ForegroundProperty.GetMetadata(typeof(FormsTextBox)).DefaultValue;