Reputation:
I got three models. How can I bind the property of my subclass?
ViewModel Object_A:
private Object_A _object_A;
public Object_A Object_A
{
get => _object_A;
set => SetValue(ref _object_A, value);
}
Object_A class:
public class Object_A : BaseViewModel
{
private Object_B _object_B;
public Object_B Object_B
{
get => _object_B;
set => SetValue(ref _object_B, value);
}
}
Object_B class:
public class Object_B : BaseViewModel
{
private string _id = string.Empty;
[JsonProperty("id")]
public string Id
{
get => _id;
set => SetValue(ref _id, value);
}
}
How can I access the property Object_A.Object_B.Id
in XAML
?
I tried Text="{Binding Object_A, Path=Object_B.Id}"
so far...
Upvotes: 1
Views: 218
Reputation: 89204
if your BindingContext
is ViewModel
, then this should work
Text="{Binding Object_A.Object_B.Id}"
Upvotes: 1