MVVMCross iOS Supported Orientations - c#

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

Related

How to implement Pointer-/MouseMoveEvents in Xamarin UWP app?

I have a Xamarin app. (Only) for the UWP app I need access to the mouse events (PointerMoved- / PointerEntered / PointerPressed-Events).
Until now my entire codebase is shared code.
Can somebody help me with forwarding the mouse events to the shared Code base? I googled a lot and nearly all answers either suggest a paid libary called "MR.Gestures" or say that it is not possible to recieve mouse Events (like this one I am not able to implement MouseUp, MouseDown and mouseMove Events in Xamarin Mobile applications). Sometimes GestureRecogniser are mentioned, but they Arent extensible, so how are they supposed to help?
Is there really no way to recieve mouse Events in xamarin?
You can do this. However it is a very extensive work to the level that you might consider to write your app in the native UWP XAML and share some C# code with the Xamarin project instead.
The way would be to extend each control that you are going to use (yes every single control that needs this effect), add to it those events and then write the UWP custom renderers that would invoke those events and then replace all controls in your XAML with those controls.
As said this may turn to be quite extensive work, but that's how it can be done.
Also if you don't need those events but just some visual effects on those events it may be possible to cut on this work by writing a custom XAML styles for those controls in app.xaml in the UWP project.

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.

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/

Implement swipe to delete for UWP

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).

No target found for method thrown by Caliburn

I'm trying to create an application which allows me to sketch some doodles on the canvas component with the help of Caliburn.Micro for MVVM. When I run the application and click on the Canvas I get "No target found for method OnMouseDown." exception. I defined the method to be called when the MouseDown event is called, but somehow Caliburn doesn't find it.
The project files are available here: SketchingTool.zip
Apparently I wired the application in a wrong way. The ViewModel it was looking for for methods was not the ViewModel they were in, because I mixed the view-first approach with the viewmodel-first approach. Fixing it according to the documentation of Caliburn fixed the problem.

Categories