MvvmCross: show a built-in iOS ViewController - c#

I want to present an MCBrowserViewController (a "native" iOS 7 View Controller) in a Xamarin.iOS app using MvvmCross. It appears that there are two ways to accomplish this (as detailed in Integrating third party controller with MVVMCross on MonoTouch):
create a Custom Presenter
inherit from MCBrowserViewController to provide an EventSource-ViewController, and inherit from the EventSource-ViewController to add the Mvx BindingContext
I have tried 1 and 2 above (I suspect that 2 is the more correct approach?), but I am not able to actually present the MCBrowserViewController. I have watched a range of the "N+1 Days of MvvmCross" tutorials but I can't seem to find a tutorial specifically on this.
Any help will be greatly appreciated! I can post the code I wrote in implementing approach 2 above if it will help.

THe EventSource inheritance approach you describe is the standard way for cases where you want to build upon the functionality of a pre-built controller.
However, if MCBrowserViewController is just a modal view which you want to "pop up" and use "as is" from within an existing view, then you can just display this view from within your app.
This is how the Tweet sharing plugin works - https://github.com/MvvmCross/MvvmCross/blob/v3.1/Plugins/Cirrious/Share/Cirrious.MvvmCross.Plugins.Share.Touch/MvxShareTask.cs
And similarly how the image picker works - https://github.com/MvvmCross/MvvmCross/blob/v3.1/Plugins/Cirrious/PictureChooser/Cirrious.MvvmCross.Plugins.PictureChooser.Touch/MvxImagePickerTask.cs (although this code is a little more complicated to read)

Related

Identifying this control for Xamarin.Forms?

This is the first Xamarin.Forms app I try to create, so please bear with me.
I'm learning about Xamarin.Forms, and I'm creating my first app (with a map) that will run in the android emulator. I've already added the map, so life is good.
I also understand that, unlike asp.net webforms or Windows forms, I cannot drag & drop controls to the form. I also don't know what the available controls for each platform look like.
With that said, I would like to add the following control to my app. I have no idea how it's called, but it's sort of a panel on the bottom half of the screen. This panel will include a list (much like a gridview).
I saw this Xamarin page with a list of standard controls, but I don't know how to identify them. Even worse, I don't know what to search for in the web.
I would like to know where I can find information on adding that control to a form and populating it with data (like an asp.net gridview)
Something like that is usually rendered using an ActionSheet
Unfortunately there isn't such a control. On iOS it is done by partially covering the screen while presenting the TableViewController. You can't do something like that on Xamarin.Forms. You can do that only on native projects.
There might be some plugins that may do some of that work for you but I don't think any of them fits your request, but you can try how far you can get with this one: https://github.com/rotorgames/Rg.Plugins.Popup
Please note that Xamarin.Forms don't cover all native controls and especially not all properties of those controls. And while you may extend their reach in various ways if you are after copying everything you see in some app it is better to think of some other technology.
Also of note, Android doesn't support everything that iOS supports, so if you see something on iOS screen (like above) it may not be supported on Android, no matter what technology you use you will have to build a very custom solution, which probably isn't part of your first app.

UWP Timeline control

I am writing a UWP app which needs to show milestones against multiple, grouped tasks along a timeline of a video. Basically showing when a task occurred in the timeline. Image below of a crappy excel mock up of what I am talking about.
I have searched and can find some charting option but they are for WPF, javascript or .Net Framework.
Was thinking I could have a go at one myself using a grid as a base and I'm OK on this front for the moment, I am wanting to know if anyone knows of any suitable timeline controls for UWP or can think of another way to visualise this sort of data using available controls.
There are a number of options for UWP if you wanting to just xaml output a DataGrid the only free one I've seen is this
https://github.com/RSuter/MyToolkit
However if your willing to fork some cash there are lots of options. The obvious solution would be which is free for non-commercial use so you can give it a test.
http://www.telerik.com/universal-windows-platform-ui which has a great datagrid
the concept would be removing the first column and adding a new one at the end in a poll
The other option which I thought about mentioning before is https://www.syncfusion.com/ they have a graph library for UWP I have never used there product so I can't really say much about it except I believe they do have a timeline graph.
This is quite old now but I have just had the same issue. After a day of research I have discovered the SyncFusion CellGrid does this perfectly.
https://help.syncfusion.com/uwp/cellgrid/getting-started

How to switch view/displayed XAML file in Visual Studio

I've been developing an windows desktop application in Visual Studio 2015, and I've been trying to figure out how to switch between different view files. Essentially when the app begins I can choose which view it is supposed to display first (i.e. MainPage.xaml), however, I have yet to find any resources that describe how to switch between the different views programmatically, say at a button click.
I'm coming from developing an app for IPhone, and in XCode switching views programmatically seems to be the intended way of doing it. My question is how do I switch the views programmatically using C#? And also, is Visual Studio different in that I should be doing this someway else?
Seems like you didn't get your answer.
If you'd like some MVVM startup points, have a look at the following:
The agile warrior: simple mvvm walkthrough
Code project: MVVM basic to advance
Code project: Model-View-ViewModel (MVVM) Explained
Alternatively, you can also have a look at my article Code Project: The Big MVVM Template.
If you'll read the article, you'll see many of the benefits of the MVVM approach (and why you'd want a framework that will help).
If you just get the code sample and run it, you can see an application running and be able to look at the parts that might interest you.
There's also this answer with lots of other mvvm related resources.
First, get to grips with MVVM. There are some good tutorials online for this.
In my experience, instead of switching the View programmatically, it's much more performant to create the views and hide/show them on demand with Visibility.Show or Visibility.Collapsed. This will result in snappy, fast applications.
As noted in the comments, MVVM is a steep learning curve, but it's worth it: an application written in MVVM is very maintainable and testable.
Update
As requested, I will recommend some tutorials on MVVM. You could read a book, but that won't really work as well as watching a tutorial video and following along with it using Visual Studio. There is something magical about copying what the tutor does as they code up the sample, you really start to understand it.
I would recommend PluralSight or, perhaps, Lynda. These are not free, but the quality is excellect and the material is comprehensive. For the record, I have no affiliation with these companies.
Assuming you used a project template, it should have generated a base class called App.xaml as an application starting point, and something like MainWindow.xaml as the base start page.
For WPF/XAML
App.Current.MainWindow = <class that implements System.Windows.Window>
If you are using Xamarin.Forms XAML, than it changes to
App.Current.MainPage = <class that implements Xamarin.Forms.Page>

How to properly adapt the app UI on different screens on W10

I'm about to start porting my WP8.1 app to W10, and looks like I'll have to make it a Universal Windows App. Now, I'm fine as for the back-end code, as I'll be able to reuse 90% of my classes (Models, ViewModels, and most of my helper classes, extension methods and converters).
The problem is for the UI: I understand I'll have to design the app for different screens and aspect rations, and I don't know how to actually implement that in code.
I mean, as for the UI scaling, I know I can use the VisualStateManager and AdaptiveTriggers to manually set the properties of the UI elements I want to adapt on any screen resolution, or I can use some converters, and that's fine.
Whan I mean is: what's the best method to have the whole UI adapt to different resolutions?
This is an example:
As you can see: the whole navigation pattern changes along the UI when on different screens. On phones, we have the contact page that covers the whole UI, while on tablets and PCs we have the contact page that's just a fraction of the UI, and the pivot pages are moved into another panel on the right. Also, many of the UI elements are completely rearranged.
And of course, some view-level back-end code will change as well.
Now, I'm wondering what's the best approach to do this whole thing.
Should I:
• Have a single XAML file (for every page) with a lot of VisualStates and stuff, and try to rearrange the UI for every screen resolution
• Have different projects with a shared project (like with W8.1 universal apps), so that I can focus on the UI on every specific device? This is the approach I'd be more comfortable with, as I'd be able to design platform specific UI elements without problems. Still, I didn't understand how to actually create a shared project and different projects for each device type in VS2015.
• Use that approach with different XAML pages that share the same code-behind file (even I'm not sure how to implement this, and how to implement platform-specific code-behind parts).
• Some other method
I mean, I'm sure I'm not the only W8.1/WP8.1 developer in trouble here, is there some kind of advice I can use? I already watched all the MVA videos about W10 development, but they didn't get into the implementation details there.
Thank you for your help
Sergio
It really depends on your project. If a UI isn't changing too drastically, I would definitely use AdaptiveTriggers. You can do a lot with very little XAML. Check out Microsoft's sample code if you haven't already: https://github.com/Microsoft/Windows-universal-samples/tree/master/xaml_responsivetechniques
If it is changing drastically, you can do it with AdaptiveTriggers, but it's probably easier to have multiple XAML files. A new way to do this in Win10 is to use DeviceFamily. Essentially, just create a folder called "DeviceFamily-Mobile", and stick a XAML view with the same file name in there. More info: http://sharpgis.net/post/2015/04/01/Creating-DeviceFamily-specific-layouts-in-a-Universal-App
Those two screenshots aren't necessarily that different, if you look at using the SplitView Control and the RelativePanel Control.
See this //build talk for more info.

WPF How to design a multi-window Application?

im looking for some tips and hints how i can build up my Application in a good way.
So here are some informations: I have at the moment the Mainwindow designed with a grid which holds 4 frames. its looking like this.
At the top is a menu which let you select the different Pages. I have for the main area about 8 pages for e.g. a settings page and 4 content pages. The Sidebar displays some additional informations which can be choosen by the user and the bottom shows only a page when 1 of the content pages are opened.
So my content pages have ViewModels behind to fill them and im trying to use commands in the near future when im understand all features of them ;). So im trying to use the MVVM way, but im very new at this.
I don't really need a navigation menu like it is given from navigation windows.
So is it the best way for an application like that to use Frames or are there any better solutions?
Frames support the built-in navigation infrastructure of WPF so they're a good choice if you plan to use that. It does have some problems (at least some people think so, including me) but for simple/small applications it will do just fine. Of course they'll also work if you want to roll your own light-weight navigation system, like I usually do. I generally navigate by sending instances of ViewModels around and setting them as the contents of windows or content controls, and letting DataTemplates 'dress' them up as they are defined in the views. For larger projects I'd always recommend one of the awesome frameworks which include navigation systems like Prism or Magellan.
Basically it all depends on your requirements; there are a lot of ways to get it right. It's good that you're trying to use MVVM, try to stick with that and it will generally automatically guide you in a good direction.
I'd suggest using a docking library like AvalonDock to spice your application up a bit... however I have a bitter experience with it as it's not MVVM-friendly. I recently spent the better part of a week wrestling with it to make it usable enough in a MVVM scenario and I'm not sure it can ever be done. There may be other libraries that handle things better, but (full-featured, like in Visual Studio) docking is a complicated matter so maybe don't go there. Sorry, I probably felt the need to vent after the AvalonDock frustrations.

Categories