What is meant by "it has Tooling Support"? - maui

I tried to follow Microsoft guidelines for Windows Applications. I will write apps using .NET MAUI.
Straight off the bat I noticed this .xaml file in the Quick Start MAUI project I created in VS2022. Personally I hadn't encountered these before, so I went to read about them.
At the Learn.Microsoft website it states this:
XAML allows developers to define user interfaces in .NET Multi-platform App UI
(.NET MAUI) apps using markup rather than code. XAML is not required in
a .NET MAUI app, but it is the recommended approach to developing your UI because
it's often more succinct, more visually coherent, and has tooling support
What does it mean "and has tooling support" in the context of using XAML, as opposed to just purely C#?

Just as Steve suggested, with the assistance of XAML Hot Reload, it can enable you to view the result of XAML changes in your running app, without having to rebuild your project. Without XAML Hot Reload, you have to build and deploy your app every time you want to view the result of a XAML change or in C# code(purely C#).
Also, XAML has several advantages over C# code(purely C#):
XAML is often more succinct and readable than equivalent code.
The parent-child hierarchy inherent in XML allows XAML to mimic with
greater visual clarity the parent-child hierarchy of user-interface
objects.

Related

Does MAUI support loading and displaying child forms inside a parent

We have a winforms application that uses parent/child forms written in .net framework. With .net framework being retired we are evaluating which .net core technology we should be looking at to convert our application to.
One of these technologies we are looking at is MAUI, there is some appeal to making our application cross platform however there isn't a lot there yet on this besides the very simple tutorials put out by Microsoft.
Does MAUI support loading and displaying child forms inside of a parent?
Or is it like WPF and only support custom controls?
Any guidance is greatly appreciated.
Depends exactly what you mean by a "form".
In Maui, by definition, a Page fills the window.
Its easy enough to make a ContentView that contains a "form". BUT, similar to WPF, you won't have some "lifecycle events" on those views. E.g. there is no event when a ContentView appears. A work-around is to put needed logic in constructor, OR have constructor attach an event handler to the containing page's OnAppearing method.
Bottom line: Its similar to WPF. But there is a work-around for whatever functionality you are accustomed to at the "form" level. (BTW, similar work-around is possible in WPF.)
For a more detailed answer, you'll need to research Maui, attempt to write equivalent Maui code. If you get stuck, Create a new question with the original WinForms code and the Maui attempt (that does not work). Explain what you want to happen, and what actually happens (or does not happen).
Bonus Tip: If you only need to run on Windows, then WinUI 3 (aka Windows Desktop App) is an alternative that may give you more functionality that you are accustomed to.
Importantly, mouse/keyboard/tooltip support in Maui is currently limited to what makes sense on mobile devices. No event for mouse hover - which also means no tooltips. No "global" key hooks (an Entry has a TextChanged event, which sees each character added to that Entry, when it has focus. But that doesn't help if you want a key to do something when no text element has focus.)
[OPINION] Full mouse/keyboard/tooltip support is often requested; I expect some solution sometime in 2023.
Bonus Tip #2: WinForms has been migrated to .Net 6+. [OPINION] Microsoft seems committed to keeping it alive. I wouldn't develop a new app on it, but for legacy WinForms code that would be the "cheapest" development option. Long-term, I would favor Maui for cross-platform, WinUI 3 for Windows only.

Create, build and run solution (two projects: library and tests) with vscode

Is it possible now to create solution with Visual Studio Code editor (on Windows, assuming that potentially I should be able to run it on Mac)?
What I need:
App
|- Library (classes, business logic)
|- Tests
Later I want to add more projects to this solution, like asp.net website, helper services, etc. Right now wanna focus on business logic, tests and POCO only (with C#).
Is the future here already? And how to do that?
Yeah, the easiest is to target DNX (the cross platform runtime) and to use the DNX project system (project.json). A good read is this: https://dotnet.readthedocs.org/en/latest/dnx/overview.html
A good (but big) example is OmniSharp (https://github.com/OmniSharp/omnisharp-roslyn) which is developed by multiple people on all different platforms.

Settings in MvvmCross Core assembly?

In porting my WPF MVVM app to MvvmCross, what would be the recommended approach for persistent user settings in the Core assembly? Currently I'm using Properties.Settings for this task. Ideally, I'd like a solution that can play nicely with ClickOnce upgrades on Windows.
Thanks!
If you only want to support WPF, then you could continue using properties.settings.
If you want to support settings using native techniques on other platforms as well, then you could create an interface/abstraction for your settings and then use dependency injection to inject an appropriate settings implementation on each platform. You could do this in a plugin if you wanted to - but for getting started it's easiest to start by injecting this in your UI projects in Setup.cs (for how to build a plugin, see https://speakerdeck.com/cirrious/plugins-in-mvvmcross)
What I would probably do... is to use a portable settings implementation - either using a simple JSON file or using a small SQLite database (accessed via SQLite-net). This would enable you to reuse exactly the same code on all platforms. I don't know how this would work with ClickOnce (I don't know much about ClickOnce) but I'm assuming ClickOnce would preserve these data files during upgrades.
For portably saving a JSON file, see https://github.com/slodge/MvvmCross-Tutorials/blob/master/Sample%20-%20CirriousConference/Cirrious.Conference.Core/Models/FavoritesSaver.cs
For using SQLite-net, see https://speakerdeck.com/cirrious/using-sqlite-dot-net-in-mvvmcross - but be aware that the nuget packages for SQLite-net still suffer from the open issue on x64/x86/ARM differences - see How to distribute processor-specific WindowsStore assemblies with nuget :/

MVC.NET Razor views rendering differently across deployments

I have a razor view in an MVC4 project that treats the same input differently in two different environments. I have a script block within an MVC section.
At my live deployment, whenever I create a less than comparison (if(a < b)), the < will be interpreted as a HTML block, and the section will render in a weird manner. Currently, I have to use Html.Raw("<"). At my development machine, I do not have this issue.
I'm sure there's a simple answer to why razor doesn't realize that the < is part of my javascript, but right now, I'm only interested in why the behavior would be different across delpoyments. I know both setups are running razor v2, since new features like conditional attributes are working in both.
What could be the cause of discrepancies such as this?
Check the file version of System.Web.Razor.dll in both environments and see whether it's 2.0.20715 in both places. We did release an update to Razor v2 that's included in the MVC 4 installer via Web PI, but isn't in the box in Visual Studio 2012, which might account for the difference in behavior that you're seeing.

GWT Designer produced code

I'm trying to understand GWT and its associated Designer plugin better. Using one of the more recent versions of GWT Designer and GWT 2.* in your application, can you give me a sense for
1) how much additional (UI) code you needed to develop by hand (outside GWT Designer), perhaps as a rough percentage? Was this code generally doing the model interface and controller part of MVC?
2) how well were you able to go between "design and code view" -- i.e. keep using GWT Designer for your GUI layout after you supplemented with hand-written code?
1) It does a lot like it generates html code, and ui:fields and binds the ui:field with a variable in java class. You have to write to your handlers. It does the model interface and controller done by hands.
2) To me it took a lot of time to switch views, to me the designer's performance was poor and I try to finish nt work inside the designer before switching to code view.