Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XAML or C# code-behind

I don't like to use XAML. I prefer to code everything in C#, but I think that I am doing things wrong.

In which cases it is better to use XAML and when do you use C#? What is your experience?

like image 768
user101375 Avatar asked Jun 16 '09 16:06

user101375


People also ask

Is XAML a programming language?

XAML is a new descriptive programming language developed by Microsoft to write user interfaces for next-generation managed applications. XAML is the language to build user interfaces for Windows and Mobile applications that use Windows Presentation Foundation (WPF), UWP, and Xamarin Forms.

Is XAML still supported?

XAML is dead. No wait - Long live XAML. XAML (Extensible Application Markup Language) started life as a simple thin UI markup layer, but has had a surprisingly eventful history. Developers on Microsoft's technology stack have been witnesses to XAML's phenomenal rise as well as its teetering on the edge of life support.

What is XAML CS?

xaml. cs is the code-behind page for MainPage. xaml. It's where you add your app logic and event handlers. Together these two files define a new class called MainPage , which inherits from Page, in the HelloWorld namespace.

Does XAML work with C++?

In C++, you can build apps with C++/CX and XAML or DirectX, or a combination of both. In addition, you can create an application that's a hybrid of these technologies, such as writing a component in C++/CX that's then used from a Windows Store app built with JavaScript/HTML.


2 Answers

Creating an entire window in C# can be a mess of code. The best thing about WPF is that XAML allows you to separate your design from your logic, making for much easier-to-read code.

I'll use C# when I need to create dynamic controls, but I tend to keep my general design, static storyboards, styles, datatemplates, etc. in XAML.

like image 174
Will Eddins Avatar answered Oct 13 '22 00:10

Will Eddins


Check out this video on MVVM in WPF. If you want wrap your head around how to organize a WPF application vis-a-vis what goes in XAML, code behind and other abstractions, this is a great place to start.

like image 42
JP Alioto Avatar answered Oct 13 '22 01:10

JP Alioto