1
次のコードがありますが、正しく動作しません。WebviewコントロールのActivityIndicator 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>
のCsファイルコードは
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を設定する必要がありますが、簡単な方法で回答を見ることもできます。 –