xamarin/Xamarin.Forms
Bound Entry CursorPosition value different between UWP and Android after TextChanged event
開放
#8,554 建立於 2019年11月18日
e/3 :clock3:hackathonhelp wantedinactivep/Androidt/bug :bug:up-for-grabs
倉庫指標
- 星標
- (5,644 顆星)
- PR 合併指標
- (30 天內沒有已合併 PR)
描述
Description
When rising a Entry TextChanged event, if CursorPosition is bound to the behavior, the value is different on UWP and Android device.
Steps to Reproduce
- attache entry TextChanged to a behavior
- bind CursorPosition to a behavior property
- run on UWP and Android device
xaml
<Entry x:Name="EntryAltitude"
Text="{Binding Altitude}"
CursorPosition="{Binding AltitudeCursorPosition}">
<Entry.Behaviors>
<behaviors:AltitudeEntryBehavior BCursorPosition="{Binding Source ={x:Reference EntryAltitude},
Path=CursorPosition,Mode=TwoWay}"/>
</Entry.Behaviors>
</Entry>
behavior:
public class AltitudeEntryBehavior : BehaviorBase<Entry>
{
public static readonly BindableProperty BCursorPositionProperty =
BindableProperty.CreateAttached("BCursorPosition", typeof(int), typeof(AltitudeEntryBehavior), 0,BindingMode.TwoWay);
public int BCursorPosition
{
get { return (int)GetValue(BCursorPositionProperty); }
set { SetValue(BCursorPositionProperty, value); }
}
private void OnEntryTextChanged(object sender, TextChangedEventArgs args)
{
int cp = Convert.ToInt32(BCursorPosition); // different on UWP and Android
some information there: https://forums.xamarin.com/discussion/174627/how-to-get-the-entry-cursorposition-in-a-textchange-behavior#latest
Expected Behavior
CursorPosition should be the same on any device
Actual Behavior
on Android, the CursorPosition is before the text has changed (emulator and device) on UWP, the CursorPosition is after the text has changed.
Basic Information
- Version with issue: Xamarin.Forms 4.3.0.947036
- Last known good version:
- IDE: VS 2019 16.3.5
- Platform Target Frameworks:
- Android: 9.0
- UWP: 16299
- Nuget Packages: Xamarin.Forms 4.3.0.947036
- Affected Devices:
- Huawei ANE-LX1
- Emulator Oreo 8.0