- Home
- Forum
- Xamarin.Forms
- Hiding a stacklayout above a listview
Hiding a stacklayout above a listview
Hello,
I have the following situation. My xaml looks like this:
<StackLayout>
some stuff in here
</StackLayout>
<ListView>
</ListView>
Now as soon as the item number 1 in listview has disappeared, I want to hide the stack layout. When it appears again, I want to show it.
I tried overriding ItemAppearing and ItemDisapearing, but they give a lot of flickering as the events probably get called multiple times.
Any idea how this can be achieved?
SIGN IN To post a reply.
2 Replies
LN
Lakshmi Natarajan
Syncfusion Team
February 17, 2020 12:57 PM UTC
Hi Sachin,
Thank you for using Syncfusion products.
We have checked the reported query “Hiding StackLayout above ListView” from our end. While analyzing, we bound the Visibility of StackLayout and changed its value in ItemAppearing and ItemDisappearing events of SfListView. But on changing visibility, ListView received the notification but the view does not updated. We are currently analyzing the reported issue and provide you further details on February 19, 2020. We appreciate your patience until then.
Regards,
Lakshmi Natarajan
LN
Lakshmi Natarajan
Syncfusion Team
February 18, 2020 05:12 AM UTC
Hi Sachin,
Sorry for the delay caused.
We have prepared sample based on your requirement. We would like to let you know that your requirement can be achieved by binding model property to IsVisible property of StackLayout. Please refer the following code snippet,
Xaml: Bind model property to IsVisible property of StackLayout
|
<StackLayout x:Name="myStack"
BackgroundColor="Red"
IsVisible="{Binding IsVisible}"
HeightRequest="100"/> |
C#: Change IsVisible on ItemAppearing and ItemDisAppearing event
|
private void ListView_ItemDisappearing(object sender, ItemDisappearingEventArgs e)
{
if((e.ItemData as Contacts).ContactName == "Kyle")
{
//To hide the StackLayout when first item is disappearing.
Device.BeginInvokeOnMainThread(() =>
{
viewModel.IsVisible = false;
});
}
}
private void ListView_ItemAppearing(object sender, ItemAppearingEventArgs e)
{
if ((e.ItemData as Contacts).ContactName == "Kyle")
{
//To show the StackLayout when first item is appearing.
Device.BeginInvokeOnMainThread(() =>
{
viewModel.IsVisible = true;
});
}
} |
We have attached the sample for the same. Please find the sample in the following link
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/AnimationSample-710730332
We hope this helps. Please let us know if you need any further assistance.
Regards,
Lakshmi Natarajan
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
SD Sachin Dabke
- Feb 14, 2020 07:20 AM UTC
- Feb 18, 2020 05:12 AM UTC