I made a custom view that extends ContentView, and I would like to use the NavigationService to handle navigation, but when I inject it in the constructor, I get this build error (apparently in CustomHeader.xaml):
Severity Code Description Project File Line Suppression State
Error The given key was not present in the dictionary.
This is my custom view code behind (CustomHeader.xaml.cs):
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CustomHeader : ContentView
{
private DelegateCommand _profilePictureTappedCommand;
public DelegateCommand ProfilePictureTappedCommand =>
_profilePictureTappedCommand ?? (_profilePictureTappedCommand = new DelegateCommand(ExecuteProfilePictureTappedCommand));
// This Prism command works just fine, it fires successfully
private void ExecuteProfilePictureTappedCommand()
{
}
public CustomHeader(INavigationService navigationService)
{
try
{
InitializeComponent();
ProfilePicture = Properties.CurrentUser.ProfilePicture;
}
catch (Exception ex)
{
throw;
}
_navigationService = navigationService;
}
}
Is it not possible to do dependency injection in a class that extends ContentView?
Just tagging you @BrianLagunas in case you have a quick answer to that.
Thanks!