依赖注入毛伊岛的导航错误
我正在将整个应用程序转换为MVVM并添加依赖性 注射。对于导航,我已经使用了
navigation.pushasync(new Date());
它有效但现在不再有效。您有一些解决方案吗?
内部date.xaml.cs
public partial class date : ContentPage
{
public date(dateViewModel vm)
{
InitializeComponent();
BindingContext = vm;
}
private void GoNav(object sender, EventArgs e)
{
Navigation.PopAsync();
}
}
c#编译错误是
cs7036没有任何参数对应于“ date.date(dateViewModel)” DateCalculator(net6.0-android),datecalculator(net6.0-ios),datecalculator(net66.0-ios)所需的形式参数“ vm”。 0-Maccatalyst),DateCalculator(Net6.0-Windows10.0.19041.0)C:\ Users \ source \ source \ repos \ datecalculator \ datecalculator \ datecalculator \ mainpage.xaml.xaml.cs 12
I am in the process of transforming my entire application to MVVM and adding Dependency
Injection. for the navigation I have used
Navigation.PushAsync(new date());
it which worked but now its no longer works. do you have some solutions.
inside date.xaml.cs
public partial class date : ContentPage
{
public date(dateViewModel vm)
{
InitializeComponent();
BindingContext = vm;
}
private void GoNav(object sender, EventArgs e)
{
Navigation.PopAsync();
}
}
the C# compile error is
CS7036 There is no argument given that corresponds to the required formal parameter 'vm' of 'date.date(dateViewModel)' dateCalculator (net6.0-android), dateCalculator (net6.0-ios), dateCalculator (net6.0-maccatalyst), dateCalculator (net6.0-windows10.0.19041.0) C:\Users\source\repos\dateCalculator\dateCalculator\MainPage.xaml.cs 12
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为
这是因为您删除了
默认类构造函数
并使用参数创建一个新的,因此当您调用new Date()
时,它无法找到构造函数没有参数(默认一个),这就是为什么错误出现的原因。解决方案
或
Cause
It is because you remove the
default class constructor
and create a new one with parameter, so when you callnew date()
it can't be able to find the constructor without parameter(the default one) , that's why the error comes.Solution
Or