问题描述
我想学习C#,似乎每个人都从使用WinForms切换到使用WPF。 WPF应用程序似乎对我来说更复杂,因为使用了用于构建窗体的.XAML文件。
我只是在真正参与之前询问,是XAML文件构建WPF应用程序的唯一方式吗?有更容易的方法吗?我知道我可以只是学习使用WinForms这似乎更容易,因为你基本上有一个Form对象,你使用代码,但像我提到我认为最好构建WPF应用程序
很多更容易,因为它更可读性和声明性,但你可以做(
例如
< Border BorderBrush =Red>
< TextBlock Text =Lorem Ipsum/>
< / Border>
vs。
code> var border = new Border();
border.BorderBrush = Brushes.Red;
var textBlock = new TextBlock();
textBlock.Text =Lorem Ipsum;
//以下步骤在XAML中通过结构隐含
border.Child = textBlock;
I am wanting to learn C# and it seems everyone is switching from using WinForms to using WPF. WPF applications seems so much more complicated to me because of the use of the .XAML files that are used to building the Forms.
I am just asking before I get really involved, is the XAML files the only way to build WPF applications? Is there an easier method? I know I could just learn to use the WinForms which seems a lot easier since you basically have a Form object that you work with code but like I mentioned I think it would be best to build WPF apps
XAML does make things a lot easier if you know how to use it because it is more readable and declarative, but you can do (pretty much) anything in C# code as well if you like.
e.g.
<Border BorderBrush="Red">
<TextBlock Text="Lorem Ipsum"/>
</Border>
vs.
var border = new Border();
border.BorderBrush = Brushes.Red;
var textBlock = new TextBlock();
textBlock.Text = "Lorem Ipsum";
// The following step is implicit in XAML via the structure
border.Child = textBlock;
这篇关于不要WPF应用程序需要使用XAML的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!