Xamarin resets Detail Property of MasterDetailPage/FlyoutPage when power saving mode is turned on - xamarin

I have a weird problem with my Xamarin App. When I turn on the power saving mode the App resets the Detail Property of my MasterDetailPage and thus navigate back to the Loginscreen. I cant really debug that.
My Navigation works like that: I create a new NavigationPage and set the Detail Property of my MasterDetailPage to the new NavigationPage.
Does anyone know why this happens?
//Edit using FlyoutPage instead of MasterDetailPage doesn't work
//Edit2 apparently that only happens on my Zebra TC26. Also it not only resets the Detail property to its default value it resets ALL variables/properties in my entire app except static ones to its default value...

Related

Static view above Shell Bottom Tabbar in Xamarin Forms

I'm using Shell in my Xamarin Forms app together with a bottom tabbar and no flyout menu.
Is it somehow possible to have a static view/control between the content page and the bottom tabbar?
(As an example, look at Spotifys mini-player that's constantly shown above the bottom tabbar)
I have tried to use a ControlTemplate in the ContentPage, but it works so-so.
When navigating between pages, the entire view is "slided away", thus it's noticeable that the control is not static and instead instantiated per each page.
Deactivating animations partially solves it but makes the application feel very static and is thus not an acceptable solution.
Anyone got an idea of how this can be solved?
It's quite easy to solve it with Xamarin.Android and Xamarin.Ios, but this needs to be done in Xamarin Forms.
Thanks in advance.

temporarily turn off scroll in ListView

Is there a way to turn off this behaviour and then back on? If my app detects that a user tries to swipe an item right, I want to be able to "tell" the ListView to temporarily stop scrolling so the user can complete the gesture.
In Android I found this, but I prefer finding something for both platforms at once- perhaps override the default touch handler?
On iOS you may set the scrollEnabled property on native view to false.
listView.ios.scrollEnabled = false;
On Android the same solution you have linked in your question should work. You will have to extend your own version of android.widget.ListView then override the createNativeView callback to inject your custom ListView instead of the default one.

How to override back button Title

I have a Xamarin Forms project, where the Android part is working fine. But in the navigation bar of my iOS App I have the problem that the title of some pages are too long.
So what I want to do is just replacing the title of the back button with the title of the page.
I already have a custom NavigationRenderer for some other adjustments in iOS.
In the ViewDidAppear Method of the NavigationRenderer I have tried:
NavigationItem.BackBarButton.Title = NavigationItem.Title;
NavigationItem.Title = "";
But it didn't changed anything. I also tried this with the RootController and even tried this with overriding in a custom ViewController. Nothing worked so far.
So my question is how can I accomplish this? Is the NavigationRenderer the wrong place to do it?
You generally set the back button title in the page the back button refers to i.e. the one before the page that is now showing.
NavigationPage.SetBackButtonTitle(this, "My Short Title");
So you would have to set it before you navigate to the new page if you want the new page title as the back button title.

Is there TOP VIEW(or window) on xamarin forms?

I'm making app with using Xamarin.forms.
I wanted to know if there is top window or view for Xamarin.forms.
I want to put something like a alert or indicator so that it remain on top depth all the time until it's gone. (even if new page is pushed.)
I can't find any view or window on XF.
Should I use each native window?
Thanks.
You can try to use Application.Current.MainPage.DisplayAlert method to display alert from the MainPage (which ordinary always exists in app).

Issue while setting WindowSoftInputMode to AdjustPan

I’m working on Xamarin forms project. I’ve many Entry fields in my application, one of them is in popup and the popup opens in the centre of the device screen. Also few entry fields are in scroll view. The issue is only with the Android Application. For iOS it’s working perfectly.
When I click on Entry field in side the popup, the soft key board is opened and the UI of my popup gets disturbed. So, I decided to set
WindowSoftInputMode = SoftInput.AdjustPan to my main Activity. This solves my UI issue of the popups but now when I click on other entry fields,my ![scroll view stops scrolling] (few entry fields are in side scrollview).I tried by using AdjustResize and rest of other soft inputs, but of no use.
Any ideas on how to get rid of this ?
On Android Xamarin.Forms Application is working on a single Android Activity, so WindowSoftInputMode is set globally. You could do a dependency injection service. On iOS it would do nothing and on Android it would set WindowSoftInputMode to your desired value. Then use it to set WindowSoftInputMode before and after showing your Popup.
In Xamarin.Forms Forms.Context is the Activity.
var window = ((Activity)Forms.Context).Window;
window.SetSoftInputMode(SoftInput.AdjustPan);
In case of
Xamarin Android
you can access window directly from mainActivity Like so:
Window.SetSoftInputMode(Android.Views.SoftInput.AdjustPan);
or in AndroidManifest.xml
<activity android:name=".myActivity"
android:label="#string/app_name"
android:screenOrientation="sensorPortrait"
android:windowSoftInputMode="adjustPan"/>

Resources