.NET MAUI equivalent of Xamarin.Android.Support.V7 packages? - c#

So I'm trying to migrate a Xamarin.Forms app to .NET MAUI, but I noticed that the Android.Support.V7 namespace isn't available in in the latter, though Xamarin.Forms has the Xamarin.Android.Support.V7 packages available. Does .NET MAUI have anything similar that I can use?
If you would like to duplicate this yourself, simply add the following line anywhere in a .NET MAUI app:
private Android.Support.V7.Widget.Toolbar toolbar;

Related

Unable to add a reference to project - UWP to Class Library project?

A WPF project and a UWP project share the same solution. Can both projects reference a common project?
"Common" - .NET 6 target framework, class library
"UWP" - targets Windows 10 Creators Update (Build 15063)
"WPF App" - .NET 6 target framework, references "WPF2"
"WPF2" - .NET 6 target framework
The "WPF" project can reference "Common" no problem, but the "UWP" project says "Unable to add a reference to project 'Common'".
Annoyingly, the error message does not give a reason why.
How to use a class from one C# project with another C# project
Common controls for UWP and WPF
Reference a class library from UWP and ASP.NET 5 (solution here)
UWP is not compatible with .NET Core or .NET 6.
If you want to share code between a WPF app and a UWP app, your shared project should target .NET Standard 2.0.
Please refer to the docs for more information about .NET Standard and the supported .NET implementations for each version.

How to use UWP functionality from a .Net 6 WPF application?

I have a WPF application built for .Net Framework.
It references a UWP library for doing things like using Start-Tiles etc.
I'm now converting this WPF application to .Net 6, but can't seem to find a way to call UWP methods from it.
How can this be achieved?
An application that targets and runs on the .NET Framework cannot consume a library that is compiled for UWP, like for example a library that was created using the Class Library (Universal Windows) template in Visual Studio.
You may use Windows Runtime APIs in your .NET Framework app though but that's another thing.
If you want to share code between a .NET Framework application and a UWP app, your project that contains the shared code should target .NET Standard. It can then be consumed from all applications that target platforms that is compatible with the version of the .NET Standard you are targeting in your class library.

How to package a WPF (.NET Core) app with XamlIslands and Desktop Bridge?

I have an application in WPF targeting .NET Core v3.1 and I'm using XamlIslands to display Windows 10 UI components. In order to use XamlIslands, I had to first migrate my app from .NET Framework to .NET Core.
I put my custom UWP components into a UWP project, which targets Win10 version 2004, min version is 1903. And in the WPF project I can reference these custom UWP components using XamlHosts.
Then, I have a Desktop Bridge project, which can package the WPF application, to be able to upload to the Microsoft Store.
The project compiles and runs correctly, I can run even the packaging project, but when I try to create a sideloaded App Package, it gives me the following error:
Project UWP is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1) / win-x64. Project UWP supports: uap10.0.18362 (UAP,Version=v10.0.18362)
Project UWP is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Project UWP supports: uap10.0.18362 (UAP,Version=v10.0.18362)
I tried to set the min version for the UWP app to windows 10, build 10240 (this is the oldest one), but the same error appeared (of course, with the updated uap version).
In this answer I read that maybe I should create a .NET Standard project? But there is no way to create a WPF application targeting .NET Standard.
How the error message says that the UWP app is not compatible with .netcore when I could build and run the whole solution? If it runs, why can't create an App Package?
How can I create an App Package then, which I can upload to the Store?
How to package a WPF (.NET Core) app with XamlIslands and bridge?
Please refer Host a custom WinRT XAML control in a WPF app using XAML Islands official document. And derive from your information, it looks you have not configured your solution to target a specific platform such as x86 or x64. Custom WinRT XAML controls are not supported in projects that target Any CPU.
And please don't forget edit your wpf project configuration
<AssetTargetFallback>uap10.0.19041</AssetTargetFallback>
I have make a code sample and I could make the package base on above steps, here is official code sample, you could download it and test to make a package.

Reference to type 'Freezable' claims it is defined in 'WindowsBase', but it could not be found

I am using the System.Windows.Media.Media3D namespace to do some matrix math/transformations in my C# console app. I would like to use .NET Core so that my console app can be run in the Linux environment. I am using .NET Core 3.0.0 Preview 5 in hopes that these WPF features have been published. I did notice in the .NET Core 3.0.0 Preview 5 announcement that WPF won't be fully published until .NET Core 3.0.0 Preview 7.
I've included references to PresentationCore and WindowsBase in my .csproj file.
When I try to use dotnet build I get multiple CS7069 errors: Reference to type 'Freezable' claims it is defined in 'WindowsBase', but could not be found.
I peeked inside of the WindowsBase.dll and confirmed that 'Freezable' is defined.
I worry that I will have to write my own library, but I figured I would try asking here first.
An answer to any of my below questions would be greatly appreciated:
Is there a way to get rid of these compiler errors and accomplish what I would like to with .NET Core 3.0.0 Preview 5? If so, how?
Is this something that will require WPF to be fully published in .NET Core 3.0.0 Preview 7, even though I don't need any visual elements?
Is there a Linux (newest Ubuntu) compatible library that will allow me to use equivalents to Point3D, Vector3D, and RotateTransform3D class methods?
Thank you!

How to create a project for Xamarin.Forms with .NET Standard (VS2017)

I tried both the .NET Standard and the Class Library (Xamarin.Forms) projects and didn't get any project for iOS and Android. I then tried Cross Platform App (Xamarin) and had to manually change the target to .NET Standard, which forced me to first remove the original NuGet packages. And now the project is littered with red squiggly lines.
So how do I create a Xamarin.Forms project targeting .NET Standard, for iOS and Android (and UWP)?
For now, you'll need to do it manually as you described above, because there is no template available.
The current release of Xamarin.Forms, v2.3.4, doesn't support NET Standard. However, Xamarin.Forms v2.3.5 does support NET Standard, and it is currently available on NuGet as a pre-release.
After manually converting your PCL to NET Standard, add Xamarin.Forms v2.3.5 to it.
I don't think there is a template for that at the moment.
If you want to put all the platform independent code into the NetStandard project create one using Cross Platform App (Xamarin) - then select Xamarin.Forms and Portable Class Library (PCL)
Then delete the PCL and (from the solution and the folder) and add a netstandard library in it's place (and reference it in the platform projects)
I'm always using the 'Shared Project' approach and adding everything non Xamarin.Forms (like ViewModels) in a separate PCL / netstandard library.

Categories

Resources