C# 如何将ListView页脚设置为IsVisible=false

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

这是页脚的XAML代码:

  <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
时)。