C# Xamarin从razor cshtml输入调用c模型方法

C# Xamarin从razor cshtml输入调用c模型方法,c#,html,razor,xamarin,C#,Html,Razor,Xamarin,我正在Xamarin中构建一个应用程序,它将显示一个webview,允许用户选择一个平台,使用OAuth进行身份验证。在webview中,将显示OAuth提供的图像,单击该图像时,应调用模型上的方法,该方法将为该平台处理OAuth。我现在似乎不知道如何从图像的onclick事件调用模型上的函数 cshtml: @数学模型 函数登录{ 应从此处调用alertModel.OpenAuthenticator。。。; } 型号: public class OAuthLogin { public

我正在Xamarin中构建一个应用程序,它将显示一个webview,允许用户选择一个平台,使用OAuth进行身份验证。在webview中,将显示OAuth提供的图像,单击该图像时,应调用模型上的方法,该方法将为该平台处理OAuth。我现在似乎不知道如何从图像的onclick事件调用模型上的函数

cshtml:

@数学模型 函数登录{ 应从此处调用alertModel.OpenAuthenticator。。。; } 型号:

public class OAuthLogin {
    public string ImageFile => ImageString();
    private SupportedPlatform Platform { get; }
    private const string GoogleImage = "Images/google.svg";
    private const string MicrosoftImage = "Images/microsoft.svg";

    public OAuthLogin(SupportedPlatform platform) {
        Platform = platform;
    }

    public void OpenAuthenticator() =>
        Authenticator.Authenticate(Platform);

    private string ImageString() {
        switch (Platform) {
            case SupportedPlatform.Google: {
                return GoogleImage;
            }
            case SupportedPlatform.Microsoft: {
                return MicrosoftImage;
            }
            default: {
                throw new NotSupportedException($"No authentication implemented for platform {Platform}.");
            }
        }
    }
}

您是否尝试过使用@Model.OpenAuthenticator之类的方法?是的,这似乎是在构建html时调用OpenAuthenricator方法,并将其返回值作为字符串放入html中。是的,您只能在服务器上调用服务器端函数。呈现视图后,您需要通过控制器action调用函数。这里没有涉及服务器,因为这个cshtml嵌入到应用程序中?假设这是同样的工作方式,我将如何通过控制器操作调用验证器?您使用的是XForms还是Classic?您需要在什么平台上使用它?您是否尝试使用@Model.OpenAuthenticator之类的工具?是的,这似乎是在构建html时调用OpenAuthenricator方法,并将其返回值作为字符串放入html中。是的,您只能在服务器上调用服务器端函数。呈现视图后,您需要通过控制器action调用函数。这里没有涉及服务器,因为这个cshtml嵌入到应用程序中?假设这是同样的工作方式,我将如何通过控制器操作调用验证器?您使用的是XForms还是Classic?你需要在什么平台上使用它?