Within my maui blazor hybrid project I can open a new window of this application. Is it possible to pass parameters?
Something like:
private void OnOpenWindowClicked()
{
var secondWindow = new Window
{
Page = new HomePage
{
test = "test";
}
};
Application.Current.OpenWindow(secondWindow);
}
And on this page something like:
@code {
[Parameter]
public string test { get; set; } = "";
}
Is this possible somehow?
Notice that Razor pages are compiled into C# classes that by default inherit from
Componentbase. So if you want to useApplication.Current.OpenWindow, you need to keep HomePage inherit fromMicrosoft.Maui.Controls.Page, e.g. NavigationPage/ContentPage.Use the following code:
Create a default MAUI Blazor Hybrid App project and then add a button and the code in Counter.razor:
Add a ContentPage to project root directory:
Here is the effect.