Entry lose focus after one change and breacking the app by moving cursor - iOS / Xamarin

Niklas_S 51 Reputation points
2021-07-14T05:55:25.787+00:00

There is an issue for that on github: https://github.com/xamarin/Xamarin.Forms/issues/14423

I am currently working on the settings page for an app.
After some time I noticed that some entries lose focus after a single change.
Which entries these are is not really random, but also not quite logical to me. It seems like the EntryCells always break in the middle, regardless of the data displayed. In this example app, I have 7 different records displayed 2 times each, so 14 entries. On my iPhone5 - iOS 12.5.4 (I know it's old) entry number 4 through entry number 11 has this problem. I also encountered this with the second beta of iOS 15 on a colleague's iPhone 12 (not the sample app but, the "main" app).

Also the app runs into an error when I try to move the cursor. Error message is also below.

The app runs smoothly with any working input field
The data is displayed and saved correctly even with only one change.
The entry is allowed to be empty.
So the problems are:

  • Loss of focus,
  • no suggestions, at least not for whole words, only for single characters
  • Termination of the app when trying to move the cursor.

Please help me and write me any time if you need more/different information. I have no idea why this behaves this way, but the order of occurrence might have something to do with it and of course the fact that it is CustomEntryCells.

Important to note:
These entries are implemented with CustomEntryCells, so they are ViewCells with 2 labels and one entry.

Download the Example: https://github.com/Nitroklas/BrokenEntryExampleProject

Mainpage / Settingspage - xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                        x:Class="ExampleProject.MainPage"
                        xmlns:local="clr-namespace:ExampleProject.View.Custom">

    <TableView Intent="Menu"
               HasUnevenRows="true">
        <TableRoot>
            <TableSection Title="Example Settings">
                <local:CustomEntryCell TextForEntry="{Binding FirstEntry, Mode=TwoWay}"/>

                <local:CustomEntryCell TextForEntry="{Binding SecondEntry, Mode=TwoWay}"/>

                <local:CustomEntryCell TextForEntry="{Binding ThirdEntry, Mode=TwoWay}"/>

                <local:CustomEntryCell TextForEntry="{Binding FourthEntry, Mode=TwoWay}"/>

                <local:CustomEntryCell TextForEntry="{Binding FifthEntry, Mode=TwoWay}"/>

                <local:CustomEntryCell TextForEntry="{Binding SixthEntry, Mode=TwoWay}"/>

                <local:CustomEntryCell TextForEntry="{Binding SeventhEntry, Mode=TwoWay}"/>

                <local:CustomEntryCell TextForEntry="{Binding FirstEntry, Mode=TwoWay}"/>

                <local:CustomEntryCell TextForEntry="{Binding SecondEntry, Mode=TwoWay}"/>

                <local:CustomEntryCell TextForEntry="{Binding ThirdEntry, Mode=TwoWay}"/>

                <local:CustomEntryCell TextForEntry="{Binding FourthEntry, Mode=TwoWay}"/>

                <local:CustomEntryCell TextForEntry="{Binding FifthEntry, Mode=TwoWay}"/>

                <local:CustomEntryCell TextForEntry="{Binding SixthEntry, Mode=TwoWay}"/>

                <local:CustomEntryCell TextForEntry="{Binding SeventhEntry, Mode=TwoWay}"/>
            </TableSection>
        </TableRoot>
    </TableView>

</ContentPage>

CodeBehind MainPage:

using ExampleProject.ViewModel;
using Xamarin.Forms;

namespace ExampleProject
{
    public partial class MainPage : ContentPage
    {
        private readonly MainPageViewModel mainPageViewModel;

        public MainPage()
        {
            InitializeComponent();

            mainPageViewModel = new MainPageViewModel();
            BindingContext = mainPageViewModel;
        }
    }
}

ViewModel MainPage:

using ExampleProject.Model;
using System.ComponentModel;
using System.Diagnostics;

namespace ExampleProject.ViewModel
{
    public class MainPageViewModel : INotifyPropertyChanged
    {

        public MainPageViewModel() { }

        public string _firstEntry = Settings.FirstEntry;
        public string _secondEntry = Settings.SecondEntry;
        public string _thirdEntry = Settings.ThirdEntry;
        public string _fourthEntry = Settings.FourthEntry;
        public string _fifthEntry = Settings.FifthEntry;
        public string _sixthEntry = Settings.SixthEntry;
        public string _seventhEntry = Settings.SeventhEntry;

        public event PropertyChangedEventHandler PropertyChanged;

        #region Properties
        public string FirstEntry
        {
            get { return _firstEntry; }
            set
            {
                _firstEntry = value.ToString();
                UpdateFirstEntry(_firstEntry);
                OnPropertyChanged(nameof(FirstEntry));
            }
        }
        public string SecondEntry
        {
            get { return _secondEntry; }
            set
            {
                _secondEntry = value.ToString();
                UpdateSecondEntry(_secondEntry);
                OnPropertyChanged(nameof(SecondEntry));
            }
        }
        public string ThirdEntry
        {
            get { return _thirdEntry; }
            set
            {
                _thirdEntry = value.ToString();
                UpdateThirdEntry(_thirdEntry);
                OnPropertyChanged(nameof(ThirdEntry));
            }
        }
        public string FourthEntry
        {
            get { return _fourthEntry; }
            set
            {
                _fourthEntry = value.ToString();
                UpdateFourthEntry(_fourthEntry);
                OnPropertyChanged(nameof(FourthEntry));
            }
        }
        public string FifthEntry
        {
            get { return _fifthEntry; }
            set
            {
                _fifthEntry = value.ToString();
                UpdateFifthEntry(_fifthEntry);
                OnPropertyChanged(nameof(FifthEntry));
            }
        }
        public string SixthEntry
        {
            get { return _sixthEntry; }
            set
            {
                _sixthEntry = value.ToString();
                UpdateSixthEntry(_sixthEntry);
                OnPropertyChanged(nameof(SixthEntry));
            }
        }
        public string SeventhEntry
        {
            get { return _seventhEntry; }
            set
            {
                _seventhEntry = value.ToString();
                UpdateSeventhEntry(_seventhEntry);
                OnPropertyChanged(nameof(SeventhEntry));
            }
        }
        #endregion

        private void UpdateFirstEntry(string value) => Settings.FirstEntry = value;
        private void UpdateSecondEntry(string value) => Settings.SecondEntry = value;
        private void UpdateThirdEntry(string value) => Settings.ThirdEntry = value;
        private void UpdateFourthEntry(string value) => Settings.FourthEntry = value;
        private void UpdateFifthEntry(string value) => Settings.FifthEntry = value;
        private void UpdateSixthEntry(string value) => Settings.SixthEntry = value;
        private void UpdateSeventhEntry(string value) => Settings.SeventhEntry = value;

        protected void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

Model - Settings:

using Xamarin.Essentials;

namespace ExampleProject.Model
{
    public static class Settings
    {
        private const string KeyFirstEntry = "firstEntry";
        private static readonly string FirstEntryDefault = "Empty 1";
        private const string KeySecondEntry = "secondEntry";
        private static readonly string SecondEntryDefault = "Empty 2";
        private const string KeyThirdEntry = "thirdEntry";
        private static readonly string ThirdEntryDefault = "Empty 3";
        private const string KeyFourthEntry = "fourthEntry";
        private static readonly string FourthEntryDefault = "Empty 4";
        private const string KeyFifthEntry = "fifthEntry";
        private static readonly string FifthEntryDefault = "Empty 5";
        private const string KeySixthEntry = "sixthEntry";
        private static readonly string SixthEntryDefault = "Empty 6";
        private const string KeySeventhEntry = "seventhEntry";
        private static readonly string SeventhEntryDefault = "Empty 7";

        public static string FirstEntry
        {
            get { return Preferences.Get(KeyFirstEntry, FirstEntryDefault); }
            set { Preferences.Set(KeyFirstEntry, value); }
        }
        public static string SecondEntry
        {
            get { return Preferences.Get(KeySecondEntry, SecondEntryDefault); }
            set { Preferences.Set(KeySecondEntry, value); }
        }
        public static string ThirdEntry
        {
            get { return Preferences.Get(KeyThirdEntry, ThirdEntryDefault); }
            set { Preferences.Set(KeyThirdEntry, value); }
        }
        public static string FourthEntry
        {
            get { return Preferences.Get(KeyFourthEntry, FourthEntryDefault); }
            set { Preferences.Set(KeyFourthEntry, value); }
        }
        public static string FifthEntry
        {
            get { return Preferences.Get(KeyFifthEntry, FifthEntryDefault); }
            set { Preferences.Set(KeyFifthEntry, value); }
        }
        public static string SixthEntry
        {
            get { return Preferences.Get(KeySixthEntry, SixthEntryDefault); }
            set { Preferences.Set(KeySixthEntry, value); }
        }
        public static string SeventhEntry
        {
            get { return Preferences.Get(KeySeventhEntry, SeventhEntryDefault); }
            set { Preferences.Set(KeySeventhEntry, value); }
        }
    }
}

The CustomEntryCells - xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms"
          xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
          x:Class="ExampleProject.View.Custom.CustomEntryCell"
          x:Name="this">
    <ViewCell.View>
        <Grid x:Name="Grid"
              Margin="0, 4, 0, 4"
              Padding="15, 10, 15, 10"
              BackgroundColor="#ddd"
              BindingContext="{Binding Source={x:Reference this}}">
            <Grid.RowDefinitions>
                <RowDefinition Height="0.2*"/>
                <RowDefinition Height="0.3*"/>
                <RowDefinition Height="0.5*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*"/>
            </Grid.ColumnDefinitions>

            <Label Text="Example Header"
                   FontSize="Large"
                   Grid.Row="0"
                   Grid.Column="0"/>

            <Entry Text="{Binding TextForEntry}"
                   TextColor="Black"
                   BackgroundColor="LightGray"
                   FontSize="Medium"
                   Grid.Row="1"
                   Grid.Column="0"/>

            <Label Text="Example Discription"
                   FontSize="Small"
                   Grid.Row="2"
                   Grid.Column="0"/>
        </Grid>
    </ViewCell.View>
</ViewCell>

CustomEntryCells - codebehind:

using System.Diagnostics;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace ExampleProject.View.Custom
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class CustomEntryCell : ViewCell
    {
        public static readonly BindableProperty TextForEntryProperty =
            BindableProperty.Create(
                propertyName: nameof(TextForEntry),
                returnType: typeof(string),
                declaringType: typeof(CustomEntryCell),
                defaultValue: "Example TextForEntry");

        public CustomEntryCell()
        {
            InitializeComponent();
        }

        public string TextForEntry
        {
            get { return (string)GetValue(TextForEntryProperty); }
            set { SetValue(TextForEntryProperty, value); }
        }
    }
}

The error I get when moving the cursor:

=================================================================
Native Crash Reporting
=================================================================
Got a segv while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
Native stacktrace:
=================================================================
0x10531abfc - /var/containers/Bundle/Application/5423B8E5-9DCB-4FCF-B6C8-4F836ED5AD0D/ExampleProject.iOS.app/ExampleProject.iOS : 
0x10531173c - /var/containers/Bundle/Application/5423B8E5-9DCB-4FCF-B6C8-4F836ED5AD0D/ExampleProject.iOS.app/ExampleProject.iOS : 
0x10531e518 - /var/containers/Bundle/Application/5423B8E5-9DCB-4FCF-B6C8-4F836ED5AD0D/ExampleProject.iOS.app/ExampleProject.iOS : mono_pmip
0x229d6a9fc - /usr/lib/system/libsystem_platform.dylib : <redacted>
0x256837c2c - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x2567f27cc - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x2567f0f70 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x25683c564 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x25683dda8 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x2565a1ac4 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x2565a9ccc - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x2565a7670 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x2565a6b9c - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x25659ac78 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x25659a3a8 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x25659a188 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x2569b27d0 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x25699285c - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x256a589d4 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x256a5b100 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x256a54330 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
0x22a0ecf1c - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : <redacted>
0x22a0ece9c - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : <redacted>
0x22a0ec784 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : <redacted>
0x22a0e76c0 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : <redacted>
0x22a0e6fb4 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : CFRunLoopRunSpecific
0x22c2e879c - /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices : GSEventRunModal
0x256978c38 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : UIApplicationMain
0x102e4ea68 - /var/containers/Bundle/Application/5423B8E5-9DCB-4FCF-B6C8-4F836ED5AD0D/ExampleProject.iOS.app/ExampleProject.iOS : 
0x102555140 - /var/containers/Bundle/Application/5423B8E5-9DCB-4FCF-B6C8-4F836ED5AD0D/ExampleProject.iOS.app/ExampleProject.iOS : 
0x102554fc4 - /var/containers/Bundle/Application/5423B8E5-9DCB-4FCF-B6C8-4F836ED5AD0D/ExampleProject.iOS.app/ExampleProject.iOS : 
0x1013bf850 - /var/containers/Bundle/Application/5423B8E5-9DCB-4FCF-B6C8-4F836ED5AD0D/ExampleProject.iOS.app/ExampleProject.iOS : 
0x101c634a0 - /var/containers/Bundle/Application/5423B8E5-9DCB-4FCF-B6C8-4F836ED5AD0D/ExampleProject.iOS.app/ExampleProject.iOS : 
0x1053218bc - /var/containers/Bundle/Application/5423B8E5-9DCB-4FCF-B6C8-4F836ED5AD0D/ExampleProject.iOS.app/ExampleProject.iOS : mono_pmip
0x1053ce308 - /var/containers/Bundle/Application/5423B8E5-9DCB-4FCF-B6C8-4F836ED5AD0D/ExampleProject.iOS.app/ExampleProject.iOS : mono_pmip
0x1053d36b4 - /var/containers/Bundle/Application/5423B8E5-9DCB-4FCF-B6C8-4F836ED5AD0D/ExampleProject.iOS.app/ExampleProject.iOS : mono_pmip
0x105306338 - /var/containers/Bundle/Application/5423B8E5-9DCB-4FCF-B6C8-4F836ED5AD0D/ExampleProject.iOS.app/ExampleProject.iOS : 
0x1054b6d7c - /var/containers/Bundle/Application/5423B8E5-9DCB-4FCF-B6C8-4F836ED5AD0D/ExampleProject.iOS.app/ExampleProject.iOS : xamarin_localized_string_format_9
0x1013bf754 - /var/containers/Bundle/Application/5423B8E5-9DCB-4FCF-B6C8-4F836ED5AD0D/ExampleProject.iOS.app/ExampleProject.iOS : 
0x229baa8e0 - /usr/lib/system/libdyld.dylib : <redacted>

=================================================================
Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x22934b530):0x22934b520  1f 00 00 f1 4d 03 00 54 0d 00 40 f9 b0 81 7d 92  ....M..T..@...}.
0x22934b530  0a 2e 41 a9 2c 00 0b 0a 4c 11 0c 8b 91 25 40 a9  ..A.,...L....%@.
0x22934b540  3f 01 01 eb 41 00 00 54 20 02 1f d6 a9 16 00 b4  ?...A..T .......
0x22934b550  9f 01 0a eb 60 00 00 54 91 25 ff a9 f9 ff ff 17  ....`..T.%......

=================================================================
Managed Stacktrace:
=================================================================
  at <unknown> <0xffffffff>
  at UIKit.UIApplication:UIApplicationMain <0x00007>
  at UIKit.UIApplication:Main <0x0002f>
  at UIKit.UIApplication:Main <0x00043>
  at ExampleProject.iOS.Application:Main <0x0007f>
  at System.Object:runtime_invoke_dynamic <0x0010f>
=================================================================

I'm getting a for me new error message by clicking in an entry, any entry at all, in the simulator.

Link to the video: https://1drv.ms/v/s!AmGVSRXX1eBTgcVIDgoNw17q20ijcw?e=aDXjZ6

I have to click everytime after writing or deleting a single character, but just in some fields.

The new error message:

2021-07-14 09:57:20.717409+0200 ExampleProject.iOS[20287:942595] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0x15dde658 ed2a1267 ab2496d7 34f186ad ... ec431c65 02d68f35 }, _LSLine=409, WrongSimulatorHash={length = 32, bytes = 0xaf25dda9 e45baa35 610eaabd 5bc09901 ... 9cbe61f3 81d7b9d9 }}
2021-07-14 09:57:20.717772+0200 ExampleProject.iOS[20287:942595] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0x15dde658 ed2a1267 ab2496d7 34f186ad ... ec431c65 02d68f35 }, _LSLine=409, WrongSimulatorHash={length = 32, bytes = 0xaf25dda9 e45baa35 610eaabd 5bc09901 ... 9cbe61f3 81d7b9d9 }}
2021-07-14 09:57:20.717863+0200 ExampleProject.iOS[20287:942595] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0x15dde658 ed2a1267 ab2496d7 34f186ad ... ec431c65 02d68f35 }, _LSLine=409, WrongSimulatorHash={length = 32, bytes = 0xaf25dda9 e45baa35 610eaabd 5bc09901 ... 9cbe61f3 81d7b9d9 }}
2021-07-14 09:57:20.718182+0200 ExampleProject.iOS[20287:942595] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0x15dde658 ed2a1267 ab2496d7 34f186ad ... ec431c65 02d68f35 }, _LSLine=409, WrongSimulatorHash={length = 32, bytes = 0xaf25dda9 e45baa35 610eaabd 5bc09901 ... 9cbe61f3 81d7b9d9 }}
2021-07-14 09:57:20.718293+0200 ExampleProject.iOS[20287:942595] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0x15dde658 ed2a1267 ab2496d7 34f186ad ... ec431c65 02d68f35 }, _LSLine=409, WrongSimulatorHash={length = 32, bytes = 0xaf25dda9 e45baa35 610eaabd 5bc09901 ... 9cbe61f3 81d7b9d9 }}
2021-07-14 09:57:20.718666+0200 ExampleProject.iOS[20287:942595] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0x15dde658 ed2a1267 ab2496d7 34f186ad ... ec431c65 02d68f35 }, _LSLine=409, WrongSimulatorHash={length = 32, bytes = 0xaf25dda9 e45baa35 610eaabd 5bc09901 ... 9cbe61f3 81d7b9d9 }}
2021-07-14 09:57:20.718774+0200 ExampleProject.iOS[20287:942595] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0x15dde658 ed2a1267 ab2496d7 34f186ad ... ec431c65 02d68f35 }, _LSLine=409, WrongSimulatorHash={length = 32, bytes = 0xaf25dda9 e45baa35 610eaabd 5bc09901 ... 9cbe61f3 81d7b9d9 }}
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,366 questions
0 comments No comments
{count} votes

Accepted answer
  1. Kyle Wang 5,531 Reputation points Microsoft Vendor
    2021-07-15T08:12:38.143+00:00

    Hi niklas-s,

    Welcome to our Microsoft Q&A platform!

    The same issue does exist in my test: After scrolling the screen, entering text into the newly loaded Entry on the screen will cause this issue. So you can submit an issue on Github.

    As a workaround, you can try to achieve it through ScrollView and StackLayout.

    First, create a ContentView and add the same Grid inside.

    <ContentView xmlns="http://xamarin.com/schemas/2014/forms"   
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  
                 x:Class="test.CustomView"  
                 x:Name="this">  
        <ContentView.Content>  
            <Grid x:Name="Grid"  
                  HeightRequest="300"  
                   Margin="0, 4, 0, 4"  
                   Padding="15, 10, 15, 10"  
                   BackgroundColor="#ddd"  
                   BindingContext="{Binding Source={x:Reference this}}">  
                <Grid.RowDefinitions>  
                    <RowDefinition Height="0.2*"/>  
                    <RowDefinition Height="0.3*"/>  
                    <RowDefinition Height="0.5*"/>  
                </Grid.RowDefinitions>  
                <Grid.ColumnDefinitions>  
                    <ColumnDefinition Width="1*"/>  
                </Grid.ColumnDefinitions>  
      
                <Label Text="Example Header"  
                        FontSize="Large"  
                        Grid.Row="0"  
                        Grid.Column="0"/>  
      
                <Entry Text="{Binding TextForEntry}"  
                        TextColor="Black"  
                        BackgroundColor="LightGray"  
                        FontSize="Medium"  
                        Grid.Row="1"  
                        Grid.Column="0"/>  
      
                <Label Text="Example Discription"  
                        FontSize="Small"  
                        Grid.Row="2"  
                        Grid.Column="0"/>  
            </Grid>  
        </ContentView.Content>  
    </ContentView>  
    

    Then, define a BindableProperty for ContentView

    public partial class CustomView : ContentView  
    {  
        public CustomView()  
        {  
            InitializeComponent();  
            //BindingContext = this;  
        }  
      
        public static readonly BindableProperty TextForEntryProperty = BindableProperty.Create(  
                                    nameof(TextForEntry),  
                                    typeof(string),  
                                    typeof(CustomView),  
                                    "test");  
        public string TextForEntry  
        {  
            get => (string)GetValue(TextForEntryProperty);  
            set => SetValue(TextForEntryProperty, value);  
        }  
    }  
    

    xaml:

    <ScrollView>  
        <StackLayout Padding="0,40,0,0">  
            <local:CustomView TextForEntry="12345"/>  
            <local:CustomView TextForEntry="12345"/>  
            ...  
        </StackLayout>  
    </ScrollView>  
    

    Regards,
    Kyle


    If the response is helpful, please click "Accept Answer" and upvote it.

    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.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.