Xamarin表单以编程方式扩展listview高度

时间:2016-04-14 14:18:46

标签: c# xaml xamarin resize xamarin.forms

这是我的xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="SetYourBudget.HomePage">
  <StackLayout Orientation="Vertical" VerticalOptions="FillAndExpand">
    <Label x:Name="lblImporto" Text="" VerticalOptions="Start" HorizontalOptions="Fill" HorizontalTextAlignment="Center"/>
    <ListView VerticalOptions="FillAndExpand" x:Name ="list">
    </ListView>
    <StackLayout Orientation="Vertical" Spacing="5" VerticalOptions="EndAndExpand" BackgroundColor="#c1c1c1" x:Name="addLayout" Padding="10">
       //I remove thrash code
    </StackLayout>
  </StackLayout>
</ContentPage>

我以编程方式为addLayout设置动画,向下滚动查看其中StackLayout的大小。这是代码,它完美地工作,他可以​​向下滚动到原来的位置:

    private async void BtnDropDown_Tapped(object sender, EventArgs e)
    {
        if (isVisible)
        {
            // hide
            // addSection is a section of the addLayout, not relevant in the operation it's only the size i need to scroll
            await addLayout.TranslateTo(0, addSection.Height + 10);
            imgDropDown.Source = Device.OnPlatform("btnMostra", "btnMostra", "btnMostra");
            isVisible= false;
        }
        else
        {
            //show
            await addLayout.TranslateTo(0, 0);
            imgDropDown.Source = Device.OnPlatform("btnNascondi", "btnNascondi", "btnNascondi");
            isVisible= true;
        }
    }

现在,我的问题如下:正如您可以通过xaml看到的那样,ListView名为list,位于布局上方向下滚动。

当我滚动下方布局时,我想要列表&#34;成长&#34;填充滚动动画释放的大小。

我发布了一个解释性图片:

enter image description here

(obv我设置了一些随机数据,它只是一个文本。我的目标只是理解调整大小)

感谢所有人,抱歉我的英语不完美

1 个答案:

答案 0 :(得分:0)

试试这个:

<ListView x:Name="someName">
  <ListView.Footer> 
    <Label Text="some text" />
  </ListView.Footer>
</ListView>
相关问题