简体   繁体   中英

Is XAML in WPF equivalent of .Designer.cs in Windows Forms apps?

Is XAML in WPF equivalent of .Designer.cs in Windows Forms apps?

Does it just provide compile-time state for the UI?

I am not sure but it looks like you can do things programmatically with XAML at run-time.

If I have a basic UI state where everything is added at run-time, then should I be looking outside the XAML stuff?

It's probably safe to look at XAML that way - although it's not entirely accurate. The XAML is compiled into BAML, and parsed at runtime - where the Windows Forms designer.cs file is just another C# file built by the designer. XAML is never directly translated into C#.

You can do everything done in XAML via code, though. Charles Petzold's WPF book actually takes this approach. It builds entire WPF applications in code before he ever introduces XAML.

In addition to Reed's input, I should mention that:

  • XAML uses XML syntax to define UI, but Form does not.
  • In XAML, it is much easier to separate UI from the logic by using code-behind-design. As UI is only XML, and they can be designed totally independent of any code-behind changes.
  • Minor changes like Button where you can set Content instead of Text, so you can set anything whereas it could be only text.
  • Data Binding and Dependency properties are way easier and better in WPF comapring to Windows.Form
  • Very easy and cool way to handle your design, as you can find there are many cool examples on the net.
  • You can use tools such as Snoop to visualize your 3D design, and can inspect and verify all your controls and events by selecting the UI. You can see what events are handled or not. This is a very cool tool, and you can find similar ones.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM