1
我有以下代碼,但它無法正常工作。帶Webview控件的活動指示器Xamarin表單不起作用
<AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0,0,1,1">
<ScrollView VerticalOptions="FillAndExpand">
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" x:Name="webViewLayout">
<WebView x:Name="webcontentcontrol" Source="{Binding WebViewSource}" VerticalOptions="FillAndExpand" HorizontalOptions="Fill"></WebView>
</StackLayout>
</ScrollView>
</StackLayout>
<StackLayout IsVisible="{Binding IsBusy}"
AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds="0.5,0.5,-1,-1">
<ActivityIndicator IsRunning="{Binding IsBusy}" Style="{StaticResource ActivityIndicatorStyle}"/>
<Label Text="Loading..." IsVisible="{Binding IsBusy}" HorizontalOptions="Center" Style="{StaticResource ActivityIndicatorLabelStyle}"/>
</StackLayout>
</AbsoluteLayout>
銫文件代碼是
public AnnouncementPage()
{
InitializeComponent();
BindWebViewControl();
}
protected override void OnAppearing()
{
webViewLayout.IsVisible = false;
IsBusy= true;
}
private async void BindWebViewControl()
{
var result = await _dataService.GetAnnouncement();
webcontentcontrol.Source = result.Data.First().WebViewSource;
IsBusy = false;
webViewLayout.IsVisible = true;
}
的問題是,標籤「正在加載中...」沒有隱瞞,和活動指示燈不顯示在屏幕上。
是使用INotifyPropertyChanged接口? –
是的,我已經實施 –
,如果你使用綁定上下文viewmodel,那麼你需要在你的viewmodel中聲明你的isBusy變量並在xaml.cs中設置Viewmodel.isBusy,但你也可以做簡單的方法來查看我的答案。 –