Implement swipe to delete for UWP - c#

Is there a way to implement swipe to delete for UWP.
I have checked the documentation about implementing ContextActions, but this gives a context menu and not the swipe to delete behavior I am looking for.
Since UWP supports this natively, anyway to override the implementation of XF?

There is no built-in Xamarin.Forms control that utilizes UWP' SwipeControl control, but you can implement it yourself by creating either a custom renderer of an existing control (see documentation here) or a entirely custom view that is rendered as SwipeControl on UWP (see documentation here).

Related

Is it possible to reference/embed an xib file into a XamarinForms view and inherit from a custom view controller?

We're using a third party SDK that defines its own views(Around 15 xib's) and uses the outlets set on the views to perform some actions. This logic resides in their SDK, driven by their CustomViewController and delegates. We use it pretty much out of the box without having to customize it further.
Is there a way to embed the entire xib into a ContentPage directly, without having to build out the views in xaml? Ideally, we'd like to embed the xibs, and use the SDK's CustomViewController as is. Maybe in a PageRenderer, which is a problem in itself because the PageRenderer is just a wrapper around a UIViewController, but we need to inherit from the CustomViewController.
While we understand that it's possible to embed native UI elements into a Forms view, what we want is to be able to embed the whole xib, and also inherit from a custom VC. Any insight into how these two problems can be tackled?
Basically you have those options, none of them is exactly what you ask and you'll have to find what works the best for you:
building a custom native view with a custom renderer
using the native pages and loading Xamarin ContentPages there as ViewControllers and mixing as you wish with your xibs
Eventually you may also try to access the root UIView and inject your subview there, but it is likely to interfere with Xamarin layout and likely to lead to problems, so do it on your own risk.

Getting Master Detail to behave on UWP just like it does on Android and IOS

I have a prism Xamarin Forms application which is being designed for both UWP, Android on IOS. This is the first UWP app that I have created. I want to have a menu that is only accessible from the first level of navigation. To do this, in the past, I have used a Master-Detail page. However, I have encountered some behaviour differences that I need some help with.
When I use a Master-Detail screen on IOS or Android it behaves like a menu only accessible to the first level of navigation. Any subpage that you might navigate from there you don't see menu it is replaced by the back button.
When I use a Master-Detail screen on UWP it's behaviour is different. The menu is available on all pages no matter how far into the navigation stack you travel. It is by default also a menu tray of items anchored on the left side of your application.
I have figured out how to make the menu collapse into the hamburger button that I am used to on an Android and IOS application by setting the parameter MasterBehavior to the value Popover. But I would like to have the menu completely disappear on any page navigated past the first level as it does on IOS of Android.
Does anyone know of a way to make this happen?
I think I can say safely that this can't be done in pure Xamarin.Forms.
To change this you would have to change to which UWP Frame the content is loaded, and I am not aware that Frame is exposed anywhere in Xamarin.Forms which means that even custom renderers cannot help.
However you may try to build the native navigation that would act like that in the UWP project and then load inside those native controls Xamarin.Forms page, that should work and deliver the results that you have requested. Not trivial and no few lines that I can show you, but if that is important for you it should be possible this way.

How to use a PIP mode in Xamarin.forms?

Tap the video player to drop in to Picture-in-Picture mode. Tapping on the PiP view will present controls which can be used to pause, show info, return to full screen, or exit the application.
Xamarin.Forms by default only contains Views that work on all platforms. For example an Entry -> EditText (android), UITextField (iOS), TextBox (UWP).
The Picture-in-picture ability is something that's only available on Android, which means Xamarin.Forms did not implement this.
The only way i could think of doing this is by exporting custom renderers that set the native control for a home-made xamarin.forums-view. I think you can find a good example here: http://blog.infernored.com/going-native-using-android-views-in-xamarin-forms, though i haven't tried it myself.
You'd basically use the SetNativeControl command in the OnElementChanged hook of the custom renderer to probably dom.xamarin.PictureInPicture.MovieView. Don't forget to export the renderers on the namespace.
Then you can use the XF view on your xaml-pages. I'll look in to making an sample.
Picture-in-picture sample for android-only: https://developer.xamarin.com/samples/monodroid/android-o/PictureInPicture/

Custom Control in Xamarin.Forms from scratch

I would like to write a custom control which will look like this one using Xamarin.Forms. I know that when we want to modify the existing control from Xamarin.Forms we are using Custom Renderers, but this control is something more than Entry and the solution is not obvious to me.
My question is how do I start working on this task? What control should I extend if I would like to use custom renderer? Is there some other more effective way to achieve this?
Looks like the linked control is extending a UIPickerView.
You have two options
Create the binding for https://github.com/nicklockwood/CountryPicker
Create your own Xamarin.Forms control, which is basically a custom renderer. You can refer the Forms source code to create the controls for it.
You should create a pure Xamarin.Forms view class and renderers (inherited from ViewRenderer) for each platform.
Please have a look at XLabs projects - it should be a good point to start:
Cross-platfrom view: Separator.cs.
Android renderer: SeparatorRenderer.cs.

MVVMCross iOS Supported Orientations

With the update of iOS(Monotouch) to 6, the method of choosing whether or not to rotate is no longer dependent solely on the ViewController.
With GetSupportedInterfaceOrientations and ShouldAutorotate being the method of doing so now, it is necessary to control the RootViewController. Otherwise the local override methods value will just be ignored.
Doing this in Objective C or even is straight Monotouch is pretty straight forward, but MVVMCross seems to handle most of the Pushing and Popping of the ViewControllers in the background, I am unable to get these methods to work with MVVMCross.
Is there some way of controlling orientation properly with MVVMCross and iOS6 or is it just not supported yet?
MvvmCross pushes and pops the viewcontrollers via a component called the presenter. This is what provides the RootController and helps it interact with its children.
It's easy to customise and override the presenter in the App Setup.cs process - you can implement and return your custom presenter in protected override IMvxTouchViewPresenter CreatePresenter().
For some examples on this, see http://slodge.blogspot.co.uk/2013/06/presenter-roundup.html

Categories