Flo*_*ian 3 listview xamarin xamarin.forms
有没有办法根据运行时的条件动态显示/隐藏ListView的标头.
<ListView x:Name="ListViewChallenges" Header="{Binding .}">
<ListView.FooterTemplate>
<DataTemplate>
<Label Text="No Elements found." IsVisible="{Binding FooterIsVisible}" />
</DataTemplate>
</ListView.FooterTemplate>
<!-- ... -->
</ListView>
Run Code Online (Sandbox Code Playgroud)
在BindingContext中,我声明了FooterIsVisible属性.当它是假的时,页脚应该是不可见的.但是这不起作用,页脚总是占用ListView底部的Label的一定空间.
这有点可能吗?
您应该能够隐藏页脚,而不是占用任何空间.我相信你需要HeightRequest在标签中设置标签FooterTemplate.你可以通过以下方式做到这一点:
<Label Text="No Elements found." IsVisible="{Binding FooterIsVisible}">
<Label.Triggers>
<Trigger TargetType="Label" Property="IsVisible" Value="False">
<Setter Property="HeightRequest" Value="0" />
</Trigger>
</Label.Triggers>
</Label>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5093 次 |
| 最近记录: |