I have Entry
element which contains a text value. That element is animated using translation effect. But the text value is not visible after animation finished and it will be visible until I click on that Entry
element (focus) and then will be visible
Click on Login_Action button and see Entry after animation finished.
Expect to be visible. In previous 3.3.x version, it worked like a charm.
Text value is not visible in Entry element after animation is done.
See projects:
XamarinTests.zip
I can confirm the text in the entry is indeed not visible, until it receives focus. I experienced something similar recently with an Entry in UWP, didn't look into it then, though — but it was not related to animations, just the Entry being weird.
I would be happy to look into this one now?
I can confirm the text in the entry is indeed not visible, until it receives focus. I experienced something similar recently with an Entry in UWP, didn't look into it then, though — but it was not related to animations, just the Entry being weird.
I would be happy to look into this one now?
@WayaFlyfeather That would be fantastic!
@Sonic3R If it's any help, it seems that your sample is working with stable versions up to, and including, 4.2.0.910310; it seems the bug is introduced in versions 4.3+. So you might want to use a 4.2 version for now.
4.2.0.910310
I can confirm that works on latest 4.2.x. Would be nice to be solved on 4.3/4.4
@Sonic3R I have just made a PR that will hopefully fix this issue. Until then, you can try to set HeightRequest on your Entry to some value; apparently this prevents the issue as well. (But is not real solution, of course.)
The workaround setting height doesn't work if used together with an animation. But if entry is not animated setting the heightrequest seems to work. Just added this style to a whole form and now the text appeared when page has loaded. If removing the style ..some entry field is loaded others not.
<Style TargetType="Entry">
<Setter Property="HeightRequest" Value="32"/>
</Style>
..
<Entry BackgroundColor="White" TextColor="#060606" Text="{Binding UserNameVM}"/>
@StanleyBroo Interesting, thanks for the info. The behavior does seem rather random with the underlying FormsTextBox as currently implemented. I also saw a problem with en Editor control (it uses the same FormsTextBox beneath the hood), where the text was not visible when HeightRequest _was_ set, but visible when it _was not_. My PR apparently also fixes that, though.
Correction animations does work when setting a heightRequest. The text shows up in the entry as expected (we animate the login screen).
However if you during debug have a breakpoint on App.OnStart() ...no text is visible in the Entry fields
Yep, rather random but at least we have a workaround so we can release an update to the users. Thanks
Just adding that this is still present in version 4.4.0.991265. I fell back to 4.2 and it resolved the issue for now.
Decided to use temporary workaround, since I don't use a lot of Entry controls and don't want to do downgrade to 4.2.
InitializeComponent();
// Fix all Entry elements.
FixElements(Children.OfType<Entry>().ToArray());
/// <summary>
/// Workaround for #8503 bug: Text is not visible on Entry element after animation finished.
/// https://github.com/xamarin/Xamarin.Forms/issues/8503
/// Expected to be fixed in Xamarin.Forms 4.5
/// </summary>
public static void FixElements(params VisualElement[] elements)
{
if (Device.RuntimePlatform != Device.UWP)
return;
Device.BeginInvokeOnMainThread(async () =>
{
foreach (var element in elements)
element.HeightRequest = element.Height;
await Task.Delay(250).ConfigureAwait(true);
});
}
Edit: updated workaround from amirvenus (see post below) works better.
Decided to use temporary workaround, since I don't use a lot of Entry controls and don't want to do downgrade to 4.2.
InitializeComponent(); // Fix all Entry elements. FixElements(Children.OfType<Entry>().ToArray());
/// <summary> /// Workaround for #8503 bug: Text is not visible on Entry element after animation finished. /// https://github.com/xamarin/Xamarin.Forms/issues/8503 /// Expected to be fixed in Xamarin.Forms 4.5 /// </summary> public static void FixElements(params VisualElement[] elements) { if (Device.RuntimePlatform != Device.UWP) return; Device.BeginInvokeOnMainThread(async () => { foreach (var element in elements) element.HeightRequest = element.Height; await Task.Delay(250).ConfigureAwait(true); }); }
My workaround is as follows:
if (Device.RuntimePlatform != Device.UWP)
return;
Device.BeginInvokeOnMainThread(async () =>
{
foreach (var element in elements)
{
element.IsEnabled = false;
element.HeightRequest = element.Height;
await Task.Delay(200).ConfigureAwait(true);
element.IsEnabled = true;
}
});
closed by #8536
I confirm that i still have an Issue on 4.5.0.356 about the editor not showing the texte without focus/resizing the page.
My trick for now is to set IsVisible to False while setting it to true when the LayoutChanged event fires, it might be transparent for me because the editor field is not visible at first sight.
Same here for me with both Entry and Edit controls. Using latest XF.
My workaround was to add HeightRequest = height; to an override of OnSizeAllocated.
@BlueFire-LLC can provide a small example to set height request in OnSizeAllocated ?
The workaround actually doesn't work. I tried everything I could think of, including focus and unfocus. It works in some places and doesn't in others. Very frustrating. Sure wished Microsoft would fix this.
After playing around some more, I got it to work by placing the code below in an override of the OnSizeAllocated event for my custom Entry and Edit controls.
element.IsEnabled = false;
element.HeightRequest = element.Height;
await Task.Delay(200).ConfigureAwait(true);
element.IsEnabled = true;
OnSizeAllocated
exists in Xamarin Page class, there should override method ?
I have created my own controls and overrode that on the control (Entry, Edit).
a simple example please for any control you want ?
public class DataEntry : Entry
{
public DataEntry()
{
}
protected override async void OnSizeAllocated(double width, double height)
{
base.OnSizeAllocated(width, height);
base.IsEnabled = false;
base.HeightRequest = base.Height;
await Task.Delay(200).ConfigureAwait(true);
base.IsEnabled = true;
}
}
Not good idea if <DataEntry ... IsEnabled="False"
... it will be enabled
I made my own solution to this issue in a custom renderer.
public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
{
Device.BeginInvokeOnMainThread(() =>
{
if (Control == null)
return;
if (string.IsNullOrEmpty(Control.Text))
return;
Control.Text += " ";
Control.Text = Control.Text.Trim();
});
return base.GetDesiredSize(widthConstraint, heightConstraint);
}
I am sure it will have a bunch of issues I am unaware of yet, but I figured I would just refresh the text in any box that had text in it by adding a space and removing it. timing every populated entry box might cause an issues.
Duplicate of #8787
Currently on the "To do-high impact" list.
@PureWeen can this merged in 4.7 ? A lot of customers complains about value visibility in some Entry controls... And with workarounds, it won't work all the time.
Most helpful comment
@PureWeen can this merged in 4.7 ? A lot of customers complains about value visibility in some Entry controls... And with workarounds, it won't work all the time.