I have a problem. I created an app, that uses a wizzard to set some of your settings, so to do that, I created a navigation page. In that navigation page I created my own NavigationBar with a back and next arrow and these functions:
private void arrowBack_Clicked(object sender, EventArgs e)
{
Navigation.PopAsync();
}
private void arrowNext_Clicked(object sender, EventArgs e)
{
Navigation.PushAsync(new Devices(), true);
}
But now every page slides in from the bottom, but I want them to slide in from the right and for back I want them to slide in from the left. Now I already found a few projects to create this like this: https://github.com/jsuarezruiz/xamarin-forms-page-transitions, but I was wondering if there isn't something much simpler, because it looks to me like a very wanted feature!
Any suggestions how to make NavigationPage animations from the sides?
The navigation that you are experiencing it is due to the fact that you are using PushModalAsync and PopModalAsync.
Using this your new page will come from the bottom of the screen.
If you change your code to use PushAsync and PopAsync instead (without the word Modal), you will get the navigation that you are looking for.
To get the sliding animation you should set the animation parameter to true, like this:
Navigation.PushAsync(page, true);
Related
I have simple Click event and want to navigate between views, but I get annoying slide up animation even that I have "false" as a parameter for animation in function. Is there any way to turn of animation effect when browsing between views in Xamarin Forms?
Thank you!
void Button_Clicked_Signup(System.Object sender, System.EventArgs e)
{
Navigation.PushModalAsync(new Signup(), false);
}
Your app is doing exactly what you're asking it to do. That annoying slide up animation is called Pushing a Modal which is happening since you are using the PushModalAsync function.
You need to the documentation and understand Hierarchical Navigation.
To fix it, you need to
Create a NavigationPage first
Pass in your current page into that
Use Navigation.PushAsync instead of Navigation.PushModalAsync
Is there a ScrollView event in xamarin that is triggered when the user forces scroll up and scroll is already at top? Many apps uses this as the "command" to update the page.
Currently, there is no PullToRefresh property or RefreshCommand for a ScrollView built into Xamarin.Forms. However, It does exist on ListView as shown in the docs, which you might be able to use instead depending on your needs.
Also, it does look like there is a PullToRefreshLayout opensource project created by James Montemagno you might be able to use to easily implement pull to refresh with a ScrollView, but it has been a while since it's last been updated.
You can use the Scrolled event handler. If the ScrollView is already positioned at the top of the contents and the user "pulls down" then Y amount will be either 0 or negative (I know this will work on Android and iOS, not sure about UWP and others).
scroll.Scrolled += (object sender, ScrolledEventArgs e) =>
{
if (e.ScrollY <= 0)
{
// scrolled when already at top of list
}
};
I have a WebView control in RelativeLayout. Sometimes Html is longer then display, so user can 'scroll' to the bottom. I want to add a button that would scroll back to top of the screen. But I'm not able to find any proper way to do this.
This button would also float at the bottom, that's why I'm using relative layout.
WebView neither RelativeLayout have property where I could scroll to top in my code-behind.
Is there any way to implement this?
You could use the WebView.Eval method. It's very simple, something like this would do:
MyButton.Clicked += (sender, e) => { MyWebView.Eval("window.scrollTo(0, 0)"); };
I am developing windows phone app.In this I want to set image slider.like image moving form right to left sides with some time interval.I have tried lot of examples but all are showing manually slide the image.but I want to slide the image automatically. please help me.
I've once created such an image carousel with a timer.
The basis to get this done is available on this post http://social.technet.microsoft.com/wiki/contents/articles/27766.windows-phone-how-to-create-a-simple-image-carousel-using-basic-windows-phone-controls.aspx
Only thing to get this triggered automatically, instead of using buttons like on the blog post, is by adding a timer to the page and on the tick event of the timer, trigger the storyboard animation.
So add a DispatcherTimer _imageTimer = new DispatcherTimer(); on your page and in the constructorset the timing and what method to call
_imageTimer.Interval = TimeSpan.FromSeconds(2.5);
_imageTimer.Tick += OnTimerTick;
No in the method that get's called when the timer goes off trigger the animation.
private void OnTimerTick(object sender, EventArgs e)
{
_scrollAnimation.From = 0;
_scrollAnimation.To = 480;
_scrollViewerStoryboard.Begin();
}
First, SelectedIndex is not exposed in markup, so you have to do it in code behind, right?
Second, I have set the binding in code behind:
Binding binding = new Binding("Main.PanoSelectedIndex.ObservedObject");
binding.Mode = BindingMode.TwoWay;
rootPano.SetBinding(Panorama.SelectedIndexProperty, binding);`
(ObservedObject implements iNotifyChanged)
The binding path points to my Main view model, and I can see that the PanoramaItem is updating the binding. However,the panorama does not respond when something else (a MVVM Light command) changes the binding. Any ideas?
Thanks,
Roger
To quote from the Windows Phone Developer FAQ
Panorama is designed so the user is in control, there fore you cannot set SelectedIndex programmatically, or force a navigation to a panorama item.
You can set the DefaultItem so that when your panorama is first launched, the panorama navigates to that item, but you can’t navigate programmatically beyond that. DefaultItem can also be used so that a back navigation feels like the item where the user was at did not change.
UPDATE: You can use the DefaultItem to save/restore the selection for a Panorama as shown below (code from Jeff Prosise's recent blog post):
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
// Save the Panorama control's SelectedIndex in page state
State["Index"] = PanoramaControl.SelectedIndex;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Restore the Panorama control's SelectedIndex
if (State.ContainsKey("Index"))
PanoramaControl.DefaultItem = PanoramaControl.Items[(int)State["Index"]];
}
As far as I know SelectedIndex is a readonly property in Panorama ( Weired why WP7 SDK made it readonly). So you will get only UI change back to your VM, and you cant update UI through the VM propertychange.
And DefaultItem is the property which used to set the index programatically.
Again the issue of programatically setting an already instantiated Panorama is that, the alignment of the Title and Panoramaitem wont be in sync. Anyway I am not discouraging but there is still some chance of hack there.