i made a custom view which displays a text.
in TestView.xaml
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="EodiRoad.TestView">
<StackLayout>
<Label Text="{Binding Test}"/>
<Label Text="this is test view"/>
</StackLayout>
</ContentView>
and the codebehind
in TestView.xaml.cs
public partial class TestView : ContentView
{
public static BindableProperty TestProperty =
BindableProperty.Create(
propertyName: "Test",
returnType: typeof(string),
declaringType: typeof(TestView),
defaultValue:"???"
);
public string Test
{
get
{ return (string)GetValue(TestProperty); }
set
{
Debug.WriteLine("test setted value = " + (string)value);
SetValue(TestProperty, value);
}
}
public TestView()
{
InitializeComponent();
BindingContext = this;
}
}
and when i use this is some other page like this
<local:TestView Test="hjhkhjk"/>
it would work just fine. But when i bind a data to it
<local:TestView Test="{Binding post.uploader.username}"/>
then it wont desplay anything...
its not a problem that post.uploader.username value is wrong or some that kind of thing. because
<Label Text="{Binding post.uploader.username}"/>
i have this code right under that malfunctioning line and it just works fine too..
what am i doing wrong here? how to fix it ..?
PropertyChanged
functionality to let the UI know your value is updated – Gerald Versluis