Hello,
Entry exposes the property SelectionLenth that returns the number of characters currently selected, but it does not tell their position in the string. May I safely assume that they start from CursorPosition?
the property SelectionLenth is not provide the position from the entry, you could use the following code to verify it.
<StackLayout>
<Entry x:Name="test_entry" TextColor="Black"/>
<Label x:Name="sel" TextColor="Black" BindingContext="{x:Reference Name=test_entry}" Text="{Binding Path=SelectionLength}"/>
<Label x:Name="cur" TextColor="Black" BindingContext="{x:Reference Name=test_entry}" Text="{Binding Path=CursorPosition}"/>
</StackLayout>
If you want to get the selected string from Entry.Text, you could use [Substring(Int32, Int32)](https://learn.microsoft.com/en-us/dotnet/api/system.string.substring?view=net-6.0#system-string-substring(system-int32-system-int32\)) to get it by Text.Substring(CursorPosition, SelectionLength)
.
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.