In xaml, value = {binding viewmodelValue}
can be passed, but I don't know how to implement it in C#.
Asked
Active
Viewed 38 times
1 Answers
0
You need to set the binding context to the ViewModel. In your view backend you can set
public partial class MySampleBackendPage : ContentPage
{
public MySampleBackendPage()
{
InitializeComponent();
this.BindingContext = new ViewModel();
}
}
This would bind your context to the view model.
Say your ViewModel class looks like this:
public class ViewModel
{
List<string> TextBoxValues = new List<string>();
}
Now You can bind it in xaml with the following:
<ListView x:Name="EmployeeView"
ItemsSource="{Binding TextBoxValues}">
<ListView.ItemTemplate>
<DataTemplate>
<Entry Text={Binding} BindingMode="TwoWay"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>

Zee
- 622
- 4
- 13