【发布时间】:2018-06-16 02:21:29
【问题描述】:
我正在使用一个名为 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中的一个c#函数
这是我在MainPage.Xaml.cs 中失败的尝试:
namespace TheOctant
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
public void UponRefresh()
{
webview.Source = "http://www.google.com";
}
}
}
但它不起作用。我这样做对吗?
【问题讨论】:
-
您的 XAML 中的命名空间是
TheOctant.MainPage,但您的MainPage在PullToRefreshTest的命名空间中,也许这就是问题所在? -
@RonBeyer 哈哈我把它改成了 PullToRefreshTest 因为我不想让任何人看到它哈哈。 oops e_e 但其实是同一个命名空间
标签: c# xamarin binding pull-to-refresh