I have a custom ViewCell which I want to use in a TableView:
public partial class InputCell : ViewCell { public static readonly BindableProperty LabelProperty = BindableProperty.Create("Label", typeof(string), typeof(InputCell)); public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(InputCell)); public string Label { get { return (string)GetValue(LabelProperty); } set { SetValue(LabelProperty, value); } } public string Text { get { return (string)GetValue(TextProperty); } set { SetValue(TextProperty, value); } } public InputCell() { InitializeComponent(); BindingContext = this; } }
I use it in my XAML-File like this:
<TableView> <TableRoot> <TableSection> <local:InputCell x:Name="IcServer" Label="Server" Text="{Binding Server}"/>
Unfortunately the Binding does not work. I can only show Data when I use Code behind Forms like:
IcServer.Text = _preferences.Server;
The ViewModel and all my Properties are working well, I tested them with simple Labels on my Form. I can type in Data via Keyboard and everything works well, only after I bound the BindingContext to my ViewModel (_preferences) the Form shows no Data.
What am I missing ?