MVVM Light DispatcherHelper in PCL - mvvm-light

Is there a timeline when MVVM Light DispatcherHelper will be available for PCL? In the official blog there is only a remark, that it's not available at the moment.

I just added a nuget package that helps you call RaisePropertyChanged from the UI thread in MvvmLight PCLs.
https://www.nuget.org/packages/Sylapse.MainThreadDispatch
Just use this.DispatchSet (() => MyProperty, ref _myProperty, value) in your property set methods.
Only Xamarin.Android and Xamarin.iOS supported so far. But UWP and other windows platforms will be added soon.

Related

What does "public App() : this(null) { }" do when using Xamarin Forms with Prism

So I was jsut wondering why in the Prism Doc and VS template this line is included in the App Class.
public App() : this(null) { }
Since today I commented it out and the App still started without any issues in both iOs and Android.
Best Regards
Basecrusher
If you don't need/want an IPlatformInitializer, it's fine to pass null, and the default implementation does so.
I guess the code is in there to remind you that you could pass an IPlatformInitializer if you needed/wanted to.
"With Xamarin.Forms you may have read how you can add the Dependency attribute for an impelementing type in your Platform Specific code and then resolve it with the Xamarin.Forms DependencyService. This is considered a major Anti-Pattern that should be avoided when you are using a proper Dependency Injection container. It is for this reason that Prism has dropped all support for working with the DependencyService as of Prism 7.0. Starting with Prism 6.3 the IPlatformInitializer was introduced. This allows you to easily register types with Prism's container."
https://prismlibrary.com/docs/xamarin-forms/dependency-injection/platform-specific-services.html

What's the proper way of setting up MvvmCross 6.0 Xamarin.Forms UWP application code?

I have my UWP Application inherited from Base class, which inherits from MvxApplication<Setup, CoreApp>:
public sealed partial class App : WindowsApplication
{
public App()
{
InitializeComponent();
}
}
public class WindowsApplication : MvxApplication<Setup, CoreApp>
{
}
public class Setup : MvxWindowsSetup<CoreApp>
{
public override IEnumerable<Assembly> GetViewAssemblies()
{
// need to do this as otherwise I receive the message that corresponding view to view model is not found
var assemblies = base.GetViewAssemblies().ToList();
assemblies.Add(typeof(Forms.App).Assembly);
return assemblies;
}
}
However, when launching it, receiving the following error message:
The type MvxContentPagePresentationAttribute is not configured in the
presenter dictionary
As I understand, all that is not proper way to launch Xamarin.Forms MvvmCross application, as UWP App and Setup should be inherited from something like MvxFormsApplication and MvxFormsWindowsSetup<CoreApp, Forms.App> respectively (to have Xamarin.Forms app properly initialized).
But:
MvxFormsApplication is not generic and doesn't provide ability of passing Forms-generic setup.
even if I inherit the App from MvxFormsApplication and use this.RegisterSetupType<MvxFormsWindowsSetupInheritor>();, Visual Studio compiler never allows me to compile the project because of some weird error message (something like The name “WindowsApplication” does not exist in the namespace “…”) (this might be some issue of Visual Studio, but I have VS 15.7 version, which expects the code to work (again, MvvmCross declares they support UWP and XF)).
So, from my understanding, if there is Xamarin.Forms app, there must be also some way of passing actually Xamarin.Forms App class to the UWP App class initialization.
MvvmCross, again, stands for UWP and Xamarin.Forms support, but I can't see any clear example of the way to setup such type of application.
MvvmCross documentation as always is quite "modest". There are some instructions about setting up MvvmCross UWP app as well as setting up MvvmCross XF iOS/Android, but the only word about MvvmCross XF UWP is:
You are now free to place your custom renderers in a different
assembly. All you have to do to make it work is to add your assembly
to the Setup.ViewAssemblies collection.
(in official website docs)
(which is still sounds weird, as iOS and Android versions don't need that additional code, which makes me think that such (current) documentation isn't quite actualized)
and
UWP, WPF
Extend App from MvxApplication. ( App : MvxApplication { } )
from MvvmCross.Forms package readme.txt file, when all other platforms, again, expect inheritance for the app classes from MvxForms*-based ones.
MvvmCross guys, any thoughts on that?
When I set up a new Xamarin.Forms project, I always follow the Playground sample in the MvvmCross GitHub as this example evolves along with the API and is always up-to-date, as it is part of the MvvmCross solution, so any commits need to preserve its functionality. So if you want to see how everything should look in a minimal UWP + Xamarin.Forms project see the Playground.Forms.UI and Playground.Forms.Uwp projects in the linked folder.

BackgroundUploader for Xamarin.Forms C#

I am working on converting my WindowsPhone project to Xamarin.Forms project.
I had a BackgroundUploader task for uploading my video files to server in background. However, I am not able to find a similar class in Xamarin Forms that does the same job.
Below is my BackgroundUploader code for WindowsPhone project.
Any kind suggestions please.
BackgroundUploader bguploader = new BackgroundUploader();
bguploader.SetRequestHeader(RequestHeader, jsonConverter.Serialize(Video));
UploadOperation upload = bguploader.CreateUpload(new Uri(url), videoFile);
Progress<UploadOperation> callback = new Progress<UploadOperation>(UploadProgress);
await upload.StartAsync().AsTask(canceltoken.Token, callback);
This is definitely a OS-specific functionality and it has no built-in solution in Xamarin.Forms.
As you mentioned BackgroundUploader is the solution working for UWP and Windows Phone.
For some info on iOS background execution check out the documentation. You will probably use NSURLSessionUploadTask.
On Android you should look into Background Services. See Android documentation.
To implement this in a cross-platform manner, you will have to create a shared interface and then provide platform-specific implementations. See Xamarin.Forms DependencyService for more details.

Xamarin Forms, no unitybootstrapper

I figure this should be very simple to fix but this is driving me totally crazy because I can't find any information about this problem.
I have created a "Blank APP (Portable)" in VS2015.
Next I used NuGet package manager to update and or install:
Xamarin.Forms v2.3.1.114
Prism.Core & Prism.Forms & Prism.Unity.Forms v6.2.0
Unity v4.0.1
--
So I want to create a bootstrapper that derives from the "UnityBootstrapper" however it can't seem to find it and suggesting to me to generate a new class.
Here are the references:
In which Assembly can I find this UnityBootstrapper?
In all the tutorials there seems to be no problem inheriting from the unitybootstrapper.
There is no more bootstrapper. As noted in the release notes, this has been removed.
https://github.com/PrismLibrary/Prism/wiki/Release-Notes-6.2.0
You should be using PrismApplication now. Also look at the getting started in the docs
https://github.com/PrismLibrary/Prism/blob/master/Documentation/Xamarin.Forms/1-GettingStarted.md

Caliburn.Micro and the Bootstrapper/BootstrapperBase Classes

I thought I would check out Caliburn.Micro. Using the old CodePlex documentation I went to implement my inherited bootstrapper class (inheriting from BootstrapperBase) and there is no BootstrapperBase/Bootstrapper class in the new GitHub version.
I have since re-downloaded the older CodePlex version and I am back in business with the tutorials etc. and the Bootstrapper classes are available.
What is happening in the latest version of Caliburn.Micro and why is there no Bootstrapper classes?
Note, I have seen:
Caliburn.Micro does not have "Bootstrapper" in a namespace in App.xaml
this does not help me.
From Rob Eisenberg's blog post on 2.0:
Remove Bootstrapper and PhoneBootstrapper, use BootstrapperBase and PhoneBootstrapperBase
There's a usage sample here.

Resources