Replies: 91 comments
-
Xaml can continue to be supported, whilst also adding in support for Xamarin's C# UI https://devblogs.microsoft.com/xamarin/c-sharp-markup-for-xamarin-forms/ Basic Example Grid grid = new Grid();
Label label = new Label { Text = "Code: " };
grid.Children.Add(label, 0, 1);
Entry entry = new Entry
{
Placeholder = "Enter number",
Keyboard = Keyboard.Numeric,
BackgroundColor = Color.AliceBlue,
TextColor = Color.Black,
FontSize = 15,
HeightRequest = 44,
Margin = fieldMargin
};
grid.Children.Add(entry, 0, 2);
Grid.SetColumnSpan(entry, 2);
entry.SetBinding(Entry.TextProperty, new Binding("RegistrationCode"));
Content = grid; https://docs.microsoft.com/en-gb/xamarin/xamarin-forms/user-interface/csharp-markup |
Beta Was this translation helpful? Give feedback.
-
We have a design team as well as a dev team. Our designers work in xaml. They aren't devs. This is how presentation frameworks were intended to be used. Devs are not generally good at UX. Designers are good at UX, but designers aren't devs. |
Beta Was this translation helpful? Give feedback.
-
Yes, I comprehend. Yet, even designers can switch vom XML to C# (or, if they prefer, VB.NET). There's no particular additional knowledge required if they stick to See my code sample above. There is not a significant difference between the XML and the C# version. Both indent the same way. Given the new C#8 features, the C# code may even be more concise. Just give it a thought. That's all I ask. |
Beta Was this translation helpful? Give feedback.
-
XAML can be consumed by other tools like Figma which designers use, and can be human readable without any knowledge of programming. They are also separated from the code files, so can be imported from a different team. Swift UI and C# UI are the same kind of solution for the same issue - but I think there is a place for both XAML and C# - and when compiled, they become the same set of Direct X instructions to the renderer. |
Beta Was this translation helpful? Give feedback.
-
Our designers wouldn't adopt C#. They aren't devs. They are arty types. They do most of their work in a tool like Illustrator then they map it out in Blend. They tweak the xaml but they don't write all the xaml themselves. In a shop that didn't have designers we wrote a lot of our layout in C#. It was ok, but I'd never want to go back. Proper designers light up your work. You sell more software. Designers pay for themselves many times over. So yes, I get what you are saying and I agree devs should have the option to write their designs in code. But without the option of designing in xaml, Project Reunion would lose shops like ours. |
Beta Was this translation helpful? Give feedback.
-
@SetTrend Please don't. XAML is easier to separate UI logic and code behind and makes UI designing easier. You can already use C# GUI if you want from Code Behind and even get rid of the XAML file. |
Beta Was this translation helpful? Give feedback.
-
Using C# to layout controls rapidly explodes in size when more complex scenarios are required, and renders the application of MVVM even more boilerplate-y (have to manually subscribe to PropertyChanged and update elements instead of using Not to mention that this whole idea would be terrible for C++ usage, which WinUI/XAML supports. |
Beta Was this translation helpful? Give feedback.
-
I think it's also really hard to maintain a designer which interacts with c# source code in both directions. The generated code must be left untouched for the designer to work properly. So it's mostly a relation "Designer to Code" as you are not supposed to change the code manually and expect the designer to understand your changes. The designer has to analyze the source and interpret instructions, and transform designer manipulation into code in the designer files. So what is the gain of having the c# source code available ? You are not supposed to manipulate it, or even know it exists. So it's an implementation detail. And about the fact that the |
Beta Was this translation helpful? Give feedback.
-
Fortunately, Flutter and SwiftUI devs can design very well. Windows team should give us something similar or better than Comet (Maui C# MVU). |
Beta Was this translation helpful? Give feedback.
-
@saint4eva Maybe as an option but XAML should not deprecated |
Beta Was this translation helpful? Give feedback.
-
Yes, it should be a viable option - writing UI in MVU C# way. Note, that I am not canvassing for the deprecation of XAML. Xaml is especially important and has been for years. But we need something viable in C# for those who love writing the UI in code. e.g. Flutter and SwiftUI - even the upcoming Maui (Comet MVU). |
Beta Was this translation helpful? Give feedback.
-
I prefer to have Xaml as default UI and UX rendering engine, Because Xaml is the most easiest and flexible UI and UX Development Framework that i have ever used. |
Beta Was this translation helpful? Give feedback.
-
Taking your replies into account, I'd like to amend my proposal and propose (and discuss) the following (which is a slight change to my original proposal): I propose to outsource the XAML part into an extension and drop it from runtime, design-time and build-time.Let me elaborate on my proposal ... With such - optional - Visual Studio extension, designers and programmers may choose whether they still want to utilize XAML (by installing the proposed VS extension) or deal with the runtime directly and fast (the expected default).
Futher rationale ... (Please pardon me for the following long essay. I'll try to lighten it up with some animations depicting the corresponding description for better reading.)
Removing all XAML parts from current XAML project types (e.g. WPF, WF, UWP, Xamarin.Forms, Uno Platform) would greatly reduce the current overhead for dealing with XAML:
Benefits are ...
The proposed extension is supposed to provide the following functionality ...
|
Beta Was this translation helpful? Give feedback.
-
I don't agree with removing XAML as a core part of WinUI and Windows App Dev. Sure allow the new C# Markup UI to be integrated and a supported option - but it will use XamlDirect in the background and for UI rendering - as will ReactNative for Windows. If you wish to use C# to create your UI, more power to you, but it will still push down to Direct X for rendering. |
Beta Was this translation helpful? Give feedback.
-
@mdtauk: And that's exactly the wrong way around. Going from C# to XamlDirect and then back to .NET isn't truely efficient. Windows 10 is currently most sluggish and greasy. We (i.e. you) should strive to enhance performance significantly. I don't think it makes sense to use a fast technology like DirectX and then contradict its performance by going back and forth through domains at runtime. If you see my proposal to outsource XAML to a separate extension, you will notice that there will be a significant performance boost at runtime because everthing happens within .NET (or WinRT). |
Beta Was this translation helpful? Give feedback.
-
However @sylveon if a poster inadvertently fails to consider all issues, that should not draw attacks as they have here. After all, this is a place for discussion. Not everyone in any discussion is going to consider all aspects that might be touched on. That's why we discuss things, to explore what we might have missed. I've unintentionlly drawn the topic away from the original post. Rather than prolong this discussion off-topic, perhaps any offensive comments should not be discussed other than with a down-vote and a link to GitHub Community Forum Code of Conduct |
Beta Was this translation helpful? Give feedback.
-
Where is this? I can't find anything handily named
I've been trying to get c++/winrt + CMake + WinUI3 working without the xaml compiler (partially because I prefer UIs as code, but mostly because I can't find the xaml compiler exe). I can create a I can instantiate various
There appears to either be a coupling to msbuild or to the https://github.com/fredemmott/cmake-cpp-winrt-winui3/blob/master/src/main.cpp (with c++/winrt and windows app sdk being fetched from nuget via the files in third-party/ in the same repository) |
Beta Was this translation helpful? Give feedback.
-
This was true at time of writing, but is unfortunately not true anymore. The XAML compiler went back to being a MSBuild task DLL. IIRC the executable compiler was always experimental.
In WinUI, the XamlControlsResources are actually instantiated in the constructor (as part of In worse case, ::winrt::Windows::Foundation::Uri resourceLocator{ L"ms-appx:///App.xaml" };
::winrt::Microsoft::UI::Xaml::Application::LoadComponent(*this, resourceLocator); So you may be able to get away with creating a raw XAML file containing just this, shipping it with your app, and then copying the code from <Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
</Application.Resources>
</Application> Hopefully that helps! |
Beta Was this translation helpful? Give feedback.
-
Thanks :)
That gives me the same problem - and also,
That (fredemmott/cmake-cpp-winrt-winui3@f00b0ab) results in:
That might just be that I need to also implement IXamlMetadataProvider , though that's a little bit more involved (and really wants the xaml compiler) |
Beta Was this translation helpful? Give feedback.
-
Since you don't have XAML metadata of your own, you can just forward to XamlControlsXamlMetaDataProvider |
Beta Was this translation helpful? Give feedback.
-
Thanks, that works perfectly: ... now to decouple my actual app from wxWidgets :D To summarize:
|
Beta Was this translation helpful? Give feedback.
-
So, swapping content is easy, but doing things 'correctly' seems to be appears more closely tied to Xaml than I thought - for example, I've got the IDL -> winmd -> cppwinrt parts of getting a xaml_typename sorted, but that then gets me back to needing to create an it seems like:
Thanks again though - I can make this work basically by abusing |
Beta Was this translation helpful? Give feedback.
-
See C# Markup 2 for a developer-friendly C# Markup API for WinUI 3 (and other .NET UI frameworks as well). WinUI 3 example using shorthand (for common property value combinations) and a few Flutter-like patterns: |
Beta Was this translation helpful? Give feedback.
-
The idea of C# markup and other UI libraries like SwiftUI, Flutter and Elm is to have a declarative UI in the programming language the rest of the application is also written in. Some comment above suggested that Xaml is superior because it is declarative falls short because programming APIs in an arbitrary programming language also can be declarative. The blueprint for code based UI shoul be far away from Windows Forms designer generated code because it is all focused on preparing the whole set of controls needed for the Window and then tweaking the details through switching visibilities and modifying control properties explicitly or with data binding. The mental shift that is needed in my opinion for programmer friendly UI technology is that user interfaces should be functions mapping a model to a view. No need for item templates, converters or other fancy stuff because an item template is just a function, a converter from model to ui is just a function... It is just code and it should be easy to do without much ceremony. The whole runtime and lifecycle supporting features like components should be hidden behind an API that takes care of instantiation, updates and destruction. Borrowed from a talk of Don Syme's, there is the example of how it is possible in Xaml to invert a Boolean condition. Needing a Converter to do that seems quite a bit of overkill. Would a UI just be code, so much seems natural in how it can be accomplished. I hope that the trend of declarative code based UIs really keeps pace and some time Microsoft is willing to make the right strategic decisions in that area. |
Beta Was this translation helpful? Give feedback.
-
The problem with that is C# markup. WinUI 3 supports C++ too so any solution needs to consider C++ as well. It can't be C# only. The initial suggestion presented here focused on C# only, then adapted the same solution to C++, ignoring all C++ specific issues this solution has (long compile time, very verbose code, very poor edit-and-continue/hot reload support, etc.). XAML never had those issues from the get go: changing xaml requires no code recompile or very little, xaml is less verbose, xaml hot reload works reliably even in C++. I haven't seen any effort from the presented alternatives to XAML to fix or alleviate these issues. |
Beta Was this translation helpful? Give feedback.
-
XAML enables clear separation between UI code and business logic. That does make certain things harder unlike a programming language, as you mentioned a converter is needed even to invert a boolean however for that XAML could have a negation operator (!) and similarly add other common operators to be used.
|
Beta Was this translation helpful? Give feedback.
-
There are some efforts to give us a better way of developing apps using only code. C# Markup is one of them and it is for those developers who love C# and MVVM. But there are some developers who love simplicity and power and would like to write the entire app in C# and MVU pattern. Both the business logic and UI codes in C# makes development of apps a breeze. Comet helps you achieve that, as it provides MVU pattern and C# for writing end-to-end business and consumer apps |
Beta Was this translation helpful? Give feedback.
-
Guess what programming languages allow: the separation of concerns. You can and should have a view model in swiftui and other ui technologies based on those ideas.
Yes, XAML could have such an operator built in but for some reason that hasn't happened in nearly 20 years. If you don't have a separate language, you don't need redundant implementations for such things. And surely, XAML can and should still be supported... At some point in time I really had fun learning WPF but the current trend is implementing UIs in a more functional style. The things that really caught me then are the free composability of controls inside other controls, templates and data binding (although I hate INotifyPropertyChanged). But those don't require XAML conceptually. If WPF would be invented now, I guess there wouldn't be XAML. There would be some clever VDOM and diffing mechanism in place that identified the areas that needed to be updated. |
Beta Was this translation helpful? Give feedback.
-
Is it just me or I feel like cramming lots of source code within SwiftUI? |
Beta Was this translation helpful? Give feedback.
-
Is it? The syntax is pretty much derived from XML, which is rather popular, and also I find code generated by Winforms designer to be very hard to keep track of. |
Beta Was this translation helpful? Give feedback.
-
Proposal: Drop XAML in favour of using .NET language directly
I suggest to drop XAML/XML and the inflation of compiler infrastructure in favour of utilizing a native .NET language for defining controls and components, just like .NET Windows Forms does.
Summary
Currently, programming in XAML (WPF, UWP, Xamarin.Forms, UNO Platform) is an unwieldy process (see rationale below). Things can be very much streamlined when dropping the current XML overhead in favour of just using intrinsic, native .NET languages to generate and edit designer files (e.g.
*.designer.cs
,*.designer.vb
), just like .NET Windows Forms does.Using XML to persist objects in .NET (or C++) leads to additional programming, knowledge, build and designer effort which is redundant if plain native .NET language files would be used for persisting objects in native
partial class
designer files.Rationale
*.designer.*
file.Comparison XML / C#
Beta Was this translation helpful? Give feedback.
All reactions