:
私は何とかこのような何かを行うことができます。
のViewModel
IsBusyプロパティを作成します。
private bool _isBusy = false;
public bool IsBusy
{
get { return _isBusy; }
set { _isBusy = value; OnPropertyChanged(nameof(IsBusy)); }
}
コンバータ
NotConverterを作成します。これは、ブール値を反転してXAMLで参照できる単なるものです。
public class NotConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return null;
var boolean = false;
if (Boolean.TryParse(value.ToString(), out boolean))
return !boolean;
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
ビュー
リファレンスあなたのXAMLの上部にあるコンバータ。
xmlns:converter="clr-namespace:MobileApp.Converter"
Pagesリソース辞書にリソースを宣言してください。
<ContentPage.Resources>
<ResourceDictionary>
<converter:NotConverter x:Key="NotConverter"/>
</ResourceDictionary>
</ContentPage.Resources>
次に、このプロパティをXAMLで使用します。
<Grid>
<ListView IsVisible="{Binding IsBusy, Converter={StaticResource NotConverter}}" />
<ActivityIndicator IsRunning="{Binding IsBusy}" IsVisible="{Binding IsBusy}" />
</Grid>
各コントロールのIsVisibleプロパティをdataIsLoadingのVMプロパティにバインドできます。またはコード – Jason