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

标签 c# xaml xamarin

这是页脚的 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>

ActivityIndi​​cator 按预期工作(当 IsLoading 设置为 false 时停止)。但是我想让整个页脚在 IsLoading 设置为 false 后消失,但我无法做到这一点。

最佳答案

您必须为 Footer 设置 BindingContext 并将 IsVisible 更改为 StackLayout:

<ListView Footer="{Binding IsLoading}">     
    <ListView.FooterTemplate >
        <DataTemplate>
            <StackLayout IsVisible="{Binding .}" Padding="8">
                <Label Text="Loading ..." HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" />
                <ActivityIndicator IsRunning="{Binding .}" Color="Blue" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" />
            </StackLayout>
        </DataTemplate>
    </ListView.FooterTemplate>
</ListView>

关于c# - 如何将 ListView 页脚设置为 IsVisible=false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38188693/

相关文章:

c# - .NET “double” 算法是否独立于平台/体系结构?

TextBox 资源中的 C# UWP 数据绑定(bind)

visual-studio - 禁用 XAML 预览

c# - 在具有相同命名空间的多个项目的解决方案中找不到命名空间

c# - Kinect 中的手形指针

c# - 按列表中的多个项目进行分组,然后求和并平均 C#

c# - 如何从默认选项创 build 置文件?

xaml - 如何将命令添加到 ListBox.ItemTemplate

facebook - Xamarin Forms + IdentityServer + 外部供应商 (Facebook/Google)

c# - Android 位置时间戳转换为 C-Sharp DateTime