我正在使用Rg.Plugins.Popup
插件在水龙头上显示弹出窗口。我的问题是如何从viewmodel类调用popuppage? (我正在使用MVVM)
我在viewmodel中使用以下代码作为tap处理程序:
public async void OnForgotPasswordAsync()
{
await Application.Current.MainPage.Navigation.PushPopupAsync(new ForgotPassword());
}
这是一个Command
这里我有popuppage的视图类
<?xml version="1.0" encoding="UTF-8"?>
<pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="WeHelp.View.ForgotPassword"
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup">
<StackLayout Margin="12" Padding="24" BackgroundColor="White" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
<StackLayout>
<Label Text="Please type your Email. Once you click on 'Send', please check your inbox or spam folder" />
<Entry Placeholder="Email" Keyboard="Email"/>
</StackLayout>
<Button Text="Send" Command="{Binding SendPassword}"/>
</StackLayout>
</pages:PopupPage>
所以,我的问题发生在命令
await Application.Current.MainPage.Navigation.PushPopupAsync(new ForgotPassword());
我得到错误Argument 2: cannot convert from 'WeHelp.View.ForgotPassword' to 'Rg.Plugins.Popup.Pages.PopupPage'
将你的xaml改成这样的东西
<pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
xmlns:animations="clr-
namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
x:Class="HealthMobile.PopPages.ForgotPassowordPop">
</pages:PopupPage>
和page.cs到
public partial class ForgotPassowordPop : PopupPage
{
}