This should be a one line solution but I've been at it for days.
Very simple beginner problem....
My Viewmodel has an Part object with Properties. eg. color etc.
private PartsExt _Part;
public PartsExt Part
{
get => _Part;
set => SetProperty(ref _Part, value);
}
My ViewModel Constructor is
public PartDetailsViewModel(INavigationService navigationService) : base (navigationService)
{
}
I get my Part no problem here:
public interface IInitialize
{
void Initialize(INavigationParameters parameters);
}
public override async void Initialize(INavigationParameters parameters)
{
if (parameters.ContainsKey("SelectedPart"))
{
Part= parameters.GetValue<PartsExt>("SelectedPart");
}
}
Question
How do I bind to the XAML (remember Prism has AutowireViewModel)
I would have thought:
Text="{Binding Part.color}"
Then thought:
xmlns:local2="clr-namespace:iBasisAppV1.ViewModels;assembly=iBasisAppV1"
<ContentPage.BindingContext>
<local2:PartDetailsViewModel />
</ContentPage.BindingContext>
But that gives error:
Type 'PartDetailsViewModel' is not usable as an object element because it is not public or does not define a public parameterless constructor or a type converter.
Next trial was setting BindingContect of Outermost StackLayout
e.g. BindingContext="{Binding Part}" and label = Text="{Binding color}"
But that gives error 'Part' property not found on 'iBasisAppV1.Models.PartsExt', target property: 'Xamarin.Forms.Label.BindingContext'
I know the answers simple but with Prism involved, its impossible to find answers.