I have a listview with an ItemsSource of a list of strings, and the DataTemplate is an entry cell text is bound to the string. If I click on the entry cell and start typing I can see my changes being made as I type, but the as soon as I click on an entry element outside of the ListView my changes are lost.
<StackLayout Orientation="Horizontal">
<Label>Number of Players</Label>
<Entry Text="3" />
</StackLayout>
<ListView Header="Players" ItemsSource="{Binding Players}">
<ListView.ItemTemplate>
<DataTemplate>
<EntryCell Text="{Binding .}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
In the viewmodel I have the following code in the constructor which adds the initial elements:
Players = new List<string>();
Players.Add("test1");
Players.Add("test2");
I also define the property for Players in the viewmodel
public List<string> Players { get; }
The only time it happens is the first time I click on the entry box next to the number of players label. If I click on empty space I can see the blue border of the selected listview item disappear but the value remains the value I changed it to, but as soon as I click on the entry the values for the entry cells in the list view revert to their original values.
I feel like I've encountered something similar in WPF, which I just responded to by adding UpdateSourceTrigger=PropertyChanged to my binding. As far as I know that isn't a thing in Xamarin.Forms (at least not yet).
Any ideas how I can keep the first value entered into the listview?
The file I'm working on is in a Xamarin.Forms Portable class library, and I'm testing it using the Universal Windows(UWP) build.