Can I use WPF's Full-screen UI on Xamarin? - c#

I'm thinking about starting to use Xamarin, is it possible to take a full-screen WPF project and use it on iOS and Android ?

No. Xamarin.Android and Xamarin.iOS expose the UI of the relevant platforms - you can't just use WPF on them.
However, if you separate out your "business logic" from the UI logic in your application, you may well be able to use the same business logic project, and just create new UI projects (one per platform). Of course, that relies on your "business logic" only requiring functionality which is available on Xamarin; more generally you'd want to create a Portable Class Library with that code in.

No this is not possible. You have to use the Native API's for User Interface on both IOS and Android when you use Xamarin.
You can definitely share a lot of code, but WPF will not work.

No. Xamarin relies on each platform's native UI stack. You cannot take a WPF UI (or a Winforms or Silverlight UI) and run it on iOS or Android. What you CAN do is take the underlying core of your WPF project (domain, services, data, business logic) and use Xamarin to create an iOS and/or Android native UI on top of it.

WPF is only supported on Windows - it's not even supported on other platforms with desktop APIs for Mono.
In general, with Xamarin, the approach is you share "logic" code, but use native UI projects for each platform.

Related

Using Native Page in Xamarin Cross Platform Application

I have Xamarin Cross Platform Application in Visual Studio 2022. I have a Main Page where i want 2 buttons.
"Take me to Android Page" Button
"Take me to iOS Page" Button
I want to create a sample NATIVE page specifically in Android Project of this Cross Platform Application and one sample NATIVE page specifically in iOS Project within this Xamarin Cross Platform Application.
When I will click on "Take me to Android Page Button", it should take me to Natively designed Page of Android and when I will click on "Take me to iOS Page Button" then it should take me to Natively designed page in iOS Project.
I hope anyone can give me any reference or sample codes to achieve this goal.
Thank You
Xamarin.Forms is designed to prevent the need to design each page for both platforms by using XAML to define shared layouts rendered at runtime using native controls. If you can expand your question to include reasons why you need to define fully native page layouts for each platform, that will help better inform answerers.
If you need the ability to create custom controls for each platform, consider custom renderers which will allow you to define platform-specific behavior for individual views in your XAML pages.
When I will click on "Take me to Android Page Button", it should take
me to Natively designed Page of Android and when I will click on "Take
me to iOS Page Button" then it should take me to Natively designed
page in iOS Project.
You can first find out what Xamarin Forms is and how it works.
From document What is Xamarin.Forms?,we know:
Xamarin.Forms is an open-source UI framework. Xamarin.Forms allows
developers to build Xamarin.Android, Xamarin.iOS, and Windows
applications from a single shared codebase.
Xamarin.Forms allows developers to create user interfaces in XAML with
code-behind in C#. These interfaces are rendered as performant native
controls on each platform.
And part Who Xamarin.Forms is for mentions that :
Xamarin.Forms is for developers with the following goals:
Share UI layout and design across platforms
Share code, test and business logic across platforms.
Write cross-platform apps in C# with Visual Studio.
So, the requirement you mentioned above is not invalid.
In addition,if you want to use native controls of the target platform in xamarin forms, you can use Xamarin.Forms Custom Renderers to achieve this.
Xamarin.Forms user interfaces are rendered using the native controls
of the target platform, allowing Xamarin.Forms applications to retain
the appropriate look and feel for each platform. Custom Renderers let
developers override this process to customize the appearance and
behavior of Xamarin.Forms controls on each platform.
Note:
We have Payment Gateway SDK for Android specific only that's why we
need to use Native forms. Can you suggest or give me some hint how we
can use them ?
Xamarin.Android offers two ways to use these libraries:
1. Create a Bindings Library that automatically wraps the library with
C# wrappers so you can invoke Java code via C# calls.
2. Use the Java Native Interface (JNI) to invoke calls in Java library
code directly. JNI is a programming framework that enables Java code
to call and be called by native applications or libraries.
For more details, check: https://learn.microsoft.com/en-us/xamarin/android/platform/binding-java-library/ .

Xamarin Forms Manage Alarm Clock

Is it posible to manage the alarm clock from Android and iOS with the same Xamarin Forms code?
I have seen that its possible with nativ code.
thanks!
No.
Xamarin.Forms is essentially an absraction layer over native code.
You will be able to create a user interface that shared between each platform you target, but you will need to write your own abstraction of the native platform API(s) that you wish to consume to get the behavior that you desire. As stated above, you can utilise the Dependency Service to achieve this.

Creating UI in DLL and use it in external apps

Sorry, I don't have much experience in programming and English and my question might be awkward. It relates to Windows 10 applications for classic desktop and touch screens.
I want to add a nice-looking touch-oriented Modern-style UI to my non-Visual Studio application. It is possible to call an external .NET assembly from my app and use its public constructors, methods, properties, and handle its events.
So I’ve created a new WPF User Control Library project in Visual Studio, replaced default User Control with a new Window, and built a dll file. Now I can use it in my app as described above. Everything seems to work fine.
Here are the questions:
Am I doing it right? Is building a dll from WPF project the only way
to make a UI dll that can be used in external applications?
How can I make the UI looks and acts like Windows Universal Apps (at least I want it to respond screen rotation)? As I understand I
cannot build a dll from Universal App projects and I have to create
WPF window, make it full screen, and add appropriate UI elements.
Is it possible to use Windows 10 contracts and extensions in such UI
dll?
If you want to share your code between different programs, you have to make it a shared library which is dll in windows. I don't know the other two questions.

WPF Plug-ins in Windows Forms application

I am used to WPF Development. But recently, i am assigned to Windows Forms projects. Fortunately, application framework supports pluggable architecture and that's why i feel i can develop plugin in WPF.
If we safely assume that framework doesn't need more than a interface to detect a plugin, I have following questions:
First of all, is it a good idea to develop WPF plugin for the given scenario?
Are there any guidelines available which i should follow? Any Examples?
Will it be a good idea to design some abstraction layer specially for WPF plugins rather than depending on interface?
Thanks in advance.
Yeah, we have huge project called "Plugins" which is basically WPF App/Windows loaded via additional app domain.
I think in your case depends if you Windows Forms are in .NET 2 or .NET3.5. If it is .NET 3.5 then you dont need additional app domain to load .NET 3.5 with WPF.
If you are already in .NET 3.5 with your WinForms, then you can use ElementHost to host your WPF inside WinForms.
Apart from few glitches (like not repainting the form sometimes), it went quite smoothly in our case
As to your Qs:
Usually it is better to do everything in WPF, but do u have a choice ? (I dont think so)
Lookup an example on WPF ElementHost
Well, I would use MVVM with WPF so that later on you can chnage the UI bit (maybe Silverlight or Win8 metro) without chnaging much of the business layer logic

Integrating Silverlight 4 webcam functions into WPF

After toying a little with the new Silverlight 4 camera features, and being really disappointed that these were not included in WPF, I looked at the Silverlight assemblies and found that they more or less delegate all work to agcore.dll.
Do you think it is a good idea to package agcore.dll with my WPF application, and copy/paste or rewrite all classes concerning cameras to WPF, to get these nice features there?
That particular approach isn't likely to work, unfortunately. There's a lot more to getting C# code to work with Silverlight than just referencing the appropriate DLL. Silverlight is actually a completely different implementation of the CLR, so you can't just call into agcore.dll from a WPF app and have it run.
If you need Silverlight features in your app, I can think of two ways to get them: (1) you could conceivably host a completely separate instance of Silverlight inside a browser control in your WPF app, though communication with that Silverlight instance becomes complicated (though not impossible); or (2) you could write your entire app in Silverlight OOB (Out-of-browser)/trusted mode.
You can try VideoCaptureElement in my WPF MediaKit. It will show a webcam in WPF. It does have a different API than the Silverlight webcam API, but it should have just as many features.

Categories