Xamarin Forms: Hide a Stack While Scrolling a list - xamarin

I have a Xamarin forms Page which is divided into 2 sections, the top 40% contains the Search controls inside a stack layout, the other 60% contains a list view. While scrolling the list view up I want to hide the Stack Layout at the top covering 40% of the screen.
I achieved to implement scroll events of the list from below reference:
https://github.com/velocitysystems/xf-controls/blob/master/XF.Controls/XF.Controls/Views/ListView.cs
I am able to hide the stackLayout but there is a lot of flickering. Any idea how can I stop the flickering? the output is not crisp and stable.

You can use animation TranslateTo for StackLayout.
Example:
OnScrolled()
{
Device.BeginInvokeOnMainThread(() => {
if (isScrollToUp)
HeaderStackLayout.TranslateTo(0,-500);
else
HeaderStackLayout.TranslateTo(0,500);
});
}

You could put the search controls as the header of the ListView:
https://developer.xamarin.com/guides/xamarin-forms/user-interface/listview/customizing-list-appearance/#Headers_and_Footers
As the header is a part of the ListView itself it will scroll as expected once you have enough content to scroll through.

Related

Xamarin.Forms MasterDetailPage with part of master visible on detail

I want to push (make visible) little part of master page to detail page like on pictures in links below. Is it possible in Xamarin.Forms?
Before swipe
After swipe
I'll be grateful for help.
Set
<ContentPage NavigationPage.HasNavigationBar="False">
Place a StackLayout or Grid that looks like the side menu shown in your image. Add a tap gesture recognizer to it.
slMenu.GestureRecognizers.Add(new TapGestureRecognizer
{
Command = new Command(() => ShowSideMenu(masterPage)),
});
private void ShowSideMenu(MasterDetailPage masterPage)
{
masterPage.IsPresented = !masterPage.IsPresented;
}
This is possible, but requires quite some work, since you can't access the width of the MasterDetailView directly.
In another post (see How to set width for MasterDetailPage in xamarin forms ) I have described how to change the width of the MasterDetail view.
While implementing that, I came across a behaviour like you want to have, though for me it was an error.
Basically the steps would be
Implement a custom version of the MasterDetail view where you can set up a custom width
Change the width of the master view so it is a bit wider than it should be
Adapt the calculations when collapsing and expanding the view so that they don't collapse the entire width
For instance if your Master View gets a width of 340 and you want the last 40 to show, make sure that when being collapsed it "only" moves by 300

How to scroll a ListView to the bottom of the page?

I have a XAML page in Xamarin Forms. I create a Grid in code behind dynamically,after loading my data. After creating the Grid I need my ScrollView to scroll to the bottom of the page, how? How can I load my grid without scrolling of it ...?
I use
scroll.ScrollToAsync(lastLabel, ScrollToPosition.End, true)
but I do not get any result.

iOS11 paged scroll view suddenly is scrollable vertically

I have an app which uses EMPageViewController to display a set of onboarding slides. My understanding is that the underlying scroll view is using paged mode to display slides.
Upon update to iOS11, I see that suddenly the slides follow the finger, so they are draggable and bounce up and down. I expect paged scroll view to be scrollable horizontally only.
How can I restrict paged scroll view to horizontal scrolling only in iOS11 ?
I tried this but it did not work
pageViewController.scrollView.alwaysBounceVertical = false
This fixes the issue:
if #available(iOS 11.0, *)
{
self.scrollView.contentInsetAdjustmentBehavior = .never
}
The behavior for determining the adjusted content offsets. This
property specifies how the safe area insets are used to modify the
content area of the scroll view.
contentInsetAdjustmentBehavior is new from iOS 11 > and the default value is automatic.
Content is always adjusted vertically when the scroll view is the
content view of a view controller that is currently displayed by a
navigation or tab bar controller. If the scroll view is horizontally
scrollable, the horizontal content offset is also adjusted when there
are nonzero safe area insets.
Which made some of my UIScrollView scroll more than they were excepted to.

Xamarin Forms label animation at bottom of screen

I'm essentially making a 'shopping cart' UI and I want it so that when the user hits the 'Add' button, a little tiny box-label appears at the bottom of the screen that says 'Added Item' or something like that.
My question is how to do that with my current set up. I am currently using a nested Grid inside of a Scroll view for the main content of the page. I want the box-label to fade in at the bottom of the screen and stay located at the bottom of the screen ontop of everything else even if you scroll, until the animation fades.
Now i figure it doesn't make sense to add it into the grid since the grid's end will be out of view in the scrolling part of the scroll view, and same for the Scroll View. I am considering nesting the entire scroll view inside of a stack layout but i fear the button will just be located at the end of the stack layout under the scroll view instead of on TOP of the scroll view. How do you recommend I achieve this effect?
I prefer not to use a custom renderer if possible due to my lack of experience in the three separate platforms.
Thanks
Make vertically oriented stack layout. When you need to add you animation add it programmatically to the stack. When it finishes remove it from stack. Your scroll view will not affect animation

howto make a grid in a WP7 app bigger than the screen size?

i have a problem with my WP7 app. i'm creating a screen where the user can make some input and then generate something.
but i can't fit the whole input into the screen size, so i would need a element which has a scroll bar or something and i can add so many elements as i which and then the user scrolls up and down. how to make this?
There is a ScrollViewer control that you can use. Put the grid in the ScrollViewer and you can then scroll around.
encapsulate your content in a <scrollviewer> That should show a scrollable content.

Resources