Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to call variable which is in different class? (Binding)

$
0
0

My Solution:
* ViewModels
* * DownloadPageViewModel.cs
* * LoginPageViewModel.cs
* Views
* * DownloadPage.xaml
* * LoginPage.xaml
* App.xaml

I have:
a entry and button in DownloadPage.xaml
a webview in LoginPage.xaml

LoginPageViewModel.cs:

public string posturl;
public string InnerBody
    public DelegateCommand<WebView> WebViewOnNavigatedCommand { get; }

    public LoginPageViewModel()
    {

        WebViewOnNavigatedCommand = new DelegateCommand<WebView>(async webView =>
        {
            InnerBody = await webView.EvaluateJavaScriptAsync("document.body.innerHTML");
            InnerBody = Regex.Unescape(InnerBody);
        });

}

namespace MyApp.ViewModels
{
public class DownloadPageViewModel : BindableBase
{

    private string _postUrl;

    public string PostUrl
    {
        get => _postUrl;
        set
        {
            if (Connectivity.NetworkAccess == NetworkAccess.None)
            {
                Status = "Status: No internet connection";
                return;
            }

            SetProperty(ref _postUrl, value);
            DownloadCommand.RaiseCanExecuteChanged();
        }
    }

I want to call
posturl from DownloadPageViewModel.cs for LoginPage webview.

InnerBody from LoginPageViewModel.cs for DownloadPageViewModel.cs


Sorry, I'm very new in this language. I've been dealing with this for a few hours but I didn't.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>