I'm using a nuget package called Refractored.XamForms.PullToRefresh
.
So my MainPage.Xaml
Has:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TheOctant"
xmlns:controls="clr-namespace:Refractored.XamForms.PullToRefresh;assembly=Refractored.XamForms.PullToRefresh"
x:Class="TheOctant.MainPage">
<StackLayout>
<ScrollView>
<controls:PullToRefreshLayout x:Name="ptrl" RefreshCommand="{Binding UponRefresh}" RefreshColor="Blue">
<local:ZoomWebView x:Name="webview" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"></local:ZoomWebView>
</controls:PullToRefreshLayout>
</ScrollView>
</StackLayout>
</ContentPage>
So look at RefreshCommand="{Binding UponRefresh}"
, I'm trying to bind it to ac# function in MainPage.Xaml.cs
So Here's my failed attempt in MainPage.Xaml.cs
:
namespace TheOctant
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
public void UponRefresh()
{
webview.Source = "http://www.google.com";
}
}
}
But it doesn't work. Am I doing this correctly?
No. As the name implies, RefreshCommand
needs to be a Command
public ICommand UponRefresh
{
get {
return new Command(async () =>
{
webview.Source = "http://www.google.com";
});
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.