我正在使用名为Refractored.XamForms.PullToRefresh
的nuget包。
所以我的MainPage.Xaml
有:
<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>
请查看RefreshCommand="{Binding UponRefresh}"
,我正在尝试将其绑定到MainPage.Xaml.cs
所以这是我在MainPage.Xaml.cs
中失败的尝试:
namespace TheOctant
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
public void UponRefresh()
{
webview.Source = "http://www.google.com";
}
}
}
但它不起作用。我这样做了吗?
答案 0 :(得分:0)
没有。顾名思义,RefreshCommand
必须是Command
public ICommand UponRefresh
{
get {
return new Command(async () =>
{
webview.Source = "http://www.google.com";
});
}
}