C# 如何将ListView页脚设置为IsVisible=false
这是页脚的XAML代码:C# 如何将ListView页脚设置为IsVisible=false,c#,xaml,xamarin,C#,Xaml,Xamarin,这是页脚的XAML代码: <ListView.FooterTemplate IsVisible="{Binding IsLoading}"> <DataTemplate> <StackLayout Padding="8"> <Label Text ="Loading ..." HorizontalOptions="CenterAndExpand" Ver
<ListView.FooterTemplate IsVisible="{Binding IsLoading}">
<DataTemplate>
<StackLayout Padding="8">
<Label Text ="Loading ..."
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand"/>
<ActivityIndicator IsRunning="{Binding IsLoading}"
Color="Blue"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand"/>
</StackLayout>
</DataTemplate>
</ListView.FooterTemplate>
ActivityIndicator
按预期工作(当IsLoading
设置为false
时停止)。但我想在IsLoading
设置为false
后使整个页脚消失,我无法实现这一点。您必须为页脚设置绑定上下文
,并将IsVisible
更改为堆栈布局
:
我已经试过了。但是,如果绑定对DataTemplate的子元素可见,它只会在列表底部留下一个空白。也就是说:以前由页脚使用的空间仍然保留,但其元素不再可见。请尝试传递可为空的IsLoading,一旦加载,请将其设置为null@AkashKava执行PropertyChanged时,它抛出System.NullReferenceException:对象引用未设置为对象的实例。
(这是新的PropertyChangedEventArgs(propertyName));
(就在IsLoading
设置为null
时)。