我怎样才能打开新窗口与剃刀组件?我尝试打开新窗口与计数器()剃刀组件得到这个错误。
@code {
private void openNewWindow(){
Window secondWindow = new Window(new Counter());
Application.Current.OpenWindow(secondWindow);
}
}
错误CS1503:论据一:无法从“项目名称.页面.计数器”转换为“Microsoft.Maui.控件.页面”
这是毛伊岛Blazor应用程序项目,我想让用户打开图表面板到新窗口。
1条答案
按热度按时间dphi5xsq1#
我挣扎了一会儿,找到了一个变通办法:https://github.com/dotnet/maui/issues/11746
此解决方法向blazor
Router
添加了一个属性来执行页面导航。基于标准MAUI Blazor模板项目,执行以下操作:
添加
StartPath
属性并注入NavigationManager
。当StartPath属性更改时,导航到新的StartPath。将
x:Name
添加到BlazorWebView
组件将
StartPath
属性添加到RootComponent
就是这样!
现在可以使用以下代码打开一个新窗口,指向 * Counter * 页面。