How do I get the blend form in uno platform project - uno-platform

When I created a uno-platform app,I got the mainpage like this:
uno-platform app default mainpage
but the blend form can not open, and how can i get the blend form!
Are there any configuration I should configure?

Related

Uno Platform app react to Android theme change

While for the most part Uno Platform apps are able to handle theme changes internally,
I have some custom code in my app that needs to react to theme change. For example when user changes from light them to dark theme here:
Android display settings for theme
In my code I can get the theme value initially like this:
var color = (Color)App.Current.Resources["SystemBaseHighColor"]
Now when the user changes theme and returns to the app I want to detect that and programmatically update some component. Is there an event I can hook into for this?
You can listen for theme changes on all platforms using the ThemeListener helper class from the Windows Community Toolkit. It's supported by recent Uno Platform versions.
Just create a new instance of ThemeListener and subscribe to the ThemeListener.ThemeChanged event.

Replace WebView with WKWebView in Xamarin Forms application

I have a webview inside my Xamarin Forms application which opens report downloaded from server in html format. Today I uploaded my archived application to app store and get information about ITMS-90809: UIWebView API Deprecation.
The problem is that I have no idea how to replace UIWebView with WKWebView in cross platform application. I've tried several solutions:
1) Creating Custom renderer for WebView - but this is no solution really because I need to inherit my new class by WebView superclass. So Apple warn me again with the same message.
2) Creating dependency service and use custom renderer in ios project only. But this is the same problem - there is still WebView reference in shared project.
So, is there any way to inject WKWebView directly to StackLayout in iOS? I know that WKWebView is iOS only and StackLayout is Xamarin.Forms component but really I don't have any idea how to do this.
Can anyone help me?
There is an issue in Github you can follow: Deprecated API Usage UIWebView
WebViewRenderer in iOS implements UIWebView, and the file stays even if you switch over the WkWebViewRenderer. That's why you get the error message.
Xamarin team is working on it and it will fixed sometime in the future.
Also, there is an Apple statement says:
The App Store will no longer accept new apps using UIWebView as of
April 2020 and app updates using UIWebView as of December 2020.
So you can still submit app with UIWebView right now and the error messgae is just a warning.
Relevant links: Make WkWebViewRenderer default for iOS WebView

Xamarin AppUriHandler

I've been struggling with the APPUriHandler to work correct using Xamarin.Forms for building a multi platform app. I am not getting the AppHandler to work correct using the "Shared pages"
Following https://learn.microsoft.com/en-us/windows/uwp/launch-resume/web-to-app-link i have managed to open the appif i launch the app manual, when using a link I get stuck on the SplashScreen
which throws an error :
Its just when using the handler that it fails. I have identified that if I add a new page on the UWP project, and navigate to that page, it works fine. My problem is using the .Net standard (Old PCL) method as it is using multi platform. Is there a way to get past this or call the LoadApplication a different way from UWP MainPage as that is where it breaks
or anything that can steer me in the right direction?

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.

Xamarin Forms IEventAggregator in iOS class crash the application

I'm using Xamarin.Forms and Prism 6.3.0
I have a class in the iOS project where I want to use the IEventAggregator. When I'm passing the IEventAggregator as a parameter to the constructor of the class, the application crashes.
A clarification, I'm trying to publish from the iOS class, not to subscribe to an event published by Xamarin.Forms.
How can I use the IEventAggregator inside a class in iOS project of Xamarin.Forms?
I don't know if there is a more elegant solution, but there is one that is working. You'll have to add the dependency to your container manually with the correct injection parameters.
In your platform specific project (iOS in this case, but it holds for Android, too) change the following line
this.LoadApplication(new App());
to
var app = new App();
this.LoadApplication();
Given your App is a PrismApplication you can now access the IUnityContainer and register your type manually
var app = new App();
app.Container.RegisterType(typeof(IServiceService),
typeof(MyServiceService),
string.Empty,
new ContainerControlledLifetimeManager(),
new InjectionConstructor(new ResolvedParameter(typeof(IEventAggregator))));
this.LoadApplication(app);
Now Unity should be able to resolve MyServiceService correctly and your app should not crash anymore. Maybe you have to remove
[assembly: Xamarin.Forms.Dependency(typeof(MyServiceService)]
but I have not tried if it crashed if it's not removed.
The answer to the question is here
In short, in the class in the iOS project add the using statement using Microsoft.Practices.Unity; and in the constractor of the class add
var ea = ((App)Xamarin.Forms.Application.Current).Container.Resolve<IEventAggregator>();
in order to get the EventAggregator.
Then you can use it to publish a message i.e.
ea.GetEvent<SomeEvent>().Publish(somePayload);

Resources