【问题标题】:Xamarin Forms IsVisible false taking up spaceXamarin Forms IsVisible 错误占用空间
【发布时间】:2017-03-17 22:03:26
【问题描述】:

我有一个带有模板切换器的列表视图,我希望在特定项目上隐藏它,所以我使用了隐藏模板。我将视图(或 StackLayout)设置为 isVisible=false 和 HeightRequest=0,这样它就不会占用空间并且不可见。但是,正如您在图片中看到的那样,它仍然占用了一个空白空间。

在下图中,有 2 条隐藏消息。 “这是一个机器人英雄卡片信息!”之前的那个。和它之后的那个。

如何做到不占用空间?

【问题讨论】:

  • 尝试将 IsEnabled 也设置为 false。
  • ListView 是否设置了HasUnevenRows=true?

标签: c# xaml xamarin.forms


【解决方案1】:

请在您的列表视图中使用 Grid。它将解决您的问题。 了解更多信息 https://forums.xamarin.com/discussion/83632/hiding-and-showing-stacklayout

<ListView x:Name="ItemList" HasUnevenRows="True">

          <ListView.ItemTemplate>
            <DataTemplate>
              <ViewCell  Appearing="Cell_OnAppearing" Tapped="ViewCell_Tapped" >
                <ViewCell.View>
             <Grid.RowDefinitions>
                <RowDefinition Height="100"/>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

          </ViewCell.View>
              </ViewCell>
            </DataTemplate>

          </ListView.ItemTemplate>

        </ListView>

谢谢

【讨论】:

    猜你喜欢
    • 2019-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多