0
我想要從一個按鈕 我的菜單列表中查看列表視圖向下滾動菜單是stacklayout所以我展示裏面並使用改變高度出現在集裝箱堆場佈局它的請求,工作正常,但我有一個問題,如果想入手隱藏菜單我的問題是堆棧佈局總是-1說的呢?我想不完全綁定我想從一個按鈕,向下滾動菜單屏幕
<StackLayout
x:Name="ParentListViewStackLayout"
BackgroundColor="#242B3A"
Margin="0,0,0,0">
<Image x:Name="imgLogo" Margin="0,60,0,15"
VerticalOptions="Center"
/>
<Image Source="{local:ImageResource BlankApp.Images.menu1.png} "
VerticalOptions="CenterAndExpand">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="btnMenuClick"/>
</Image.GestureRecognizers>
</Image>
<StackLayout
Spacing="0"
x:Name="ListViewStackLayout">
<ListView x:Name="MenuListView" ItemsSource="{Binding
MenuModals}"
SeparatorColor="{StaticResource ControlTextColor}"
ItemSelected="MenuListView_OnItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell >
<ViewCell.View>
<controls:CustomStackLayout>
<Label Text="{Binding MenuName}" FontSize="Medium" HorizontalOptions="Center" Style="{StaticResource LableStyle}" Margin="0,0,0,0"/>
<Label Text="{Binding MenuDescription}" FontSize="Micro" HorizontalOptions="Center" Style="{StaticResource LableStyle}" />
<Label Text="" FontSize="Micro" HorizontalOptions="Center" Style="{StaticResource LableStyle}" HeightRequest="25" />
</controls:CustomStackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</StackLayout>
代碼佈局Begind
public WashInternational()
{
InitializeComponent();
this.BindingContextChanged += OnBindingContextChanged;
MenuListView.BindingContextChanged += MenuListViewOnBindingContextChanged;
}
private void OnBindingContextChanged(object sender, EventArgs eventArgs)
{
ShowMenue(false);
}
private void MenuListViewOnBindingContextChanged(object sender, EventArgs eventArgs)
{
ShowMenue(false);
}
public void ShowMenue(bool isShow)
{
if (isShow == _isMenuShow) return;
var height = ListViewStackLayout.Height;
if (_menuHeight <= 0)
{
_menuHeight = height;
}
_isMenuShow = isShow;
if (isShow)
{
//MenuListView.TranslateTo(0, 0, 1000);
ParentListViewStackLayout.HeightRequest = ParentListViewStackLayout.Height + _menuHeight;
//ListViewStackLayout.ScaleTo(1, 500, Easing.Linear);
}
else
{
ParentListViewStackLayout.HeightRequest = ParentListViewStackLayout.Height - _menuHeight;
//MenuListView.TranslateTo(0,- 500, 1000);
//ListViewStackLayout.ScaleTo(0, 500, Easing.Linear);
}
}
該代碼工作正常b UT斯達康我在初始狀態的問題,我無法啓動我的應用程序和menue被隱藏,因爲我不知道訪問我的棧佈局的高度正確的地方
我試過這個解決方案,但仍堆棧佈局的高度-1 –