I am trying to open a new page from another viewmodel.
I am doing this:
My pages are registered:
builder.Services.AddSingleton<SettingsPageView, SettingsPageViewModel>();
builder.Services.AddSingleton<WifiPageView, WifiPageViewModel>();
In my SetttingsPageView i do this:
<Button TextColor="Black" Command="{Binding ClickedWifiMenuCommand}" Text="WIFI Menu"/>
And the command like this:
[RelayCommand]
public async void ClickedWifiMenu()
{
Navigation.PushAsync(new WifiPageView());
}
But this is not working.
my Wifipage:
public partial class WifiPageViewModel: ObservableObject
{
private readonly ILocalizationResourceManager _loc;
private readonly ILogger _logger;
public WifiPageViewModel(ILocalizationResourceManager loc, ILogger logger)
{
_loc = loc;
_logger = logger.ForContext<WifiPageViewModel>();
}
code behind:
public WifiPageView(WifiPageViewModel vm)
{
InitializeComponent();
BindingContext = vm;
}
and my empty view:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
...
x:DataType="ViewModels:WifiPageViewModel">
<StackLayout>
<Label Text="Hi mom"/>
</StackLayout>
</ContentPage>
How can I open my view from my one view?