XAML或者C#代码隐藏 [英] XAML or C# code-behind

查看:102
本文介绍了XAML或者C#代码隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不喜欢用XAML。我宁愿代码在C#中的一切,但我认为我做的事情是错误的。

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

在这情况下,它是更好地使用XAML和什么时候使用C#?你的经验是什么?

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

推荐答案

在C#创建一个完整的窗口可以是码得一塌糊涂。有关WPF的最好的事情是,XAML允许您的设计从逻辑中分离出来,从而为更容易阅读的代码。

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.

在我,我会使用C#需要建立动态的控制,但我倾向于保持我的总体设计,静态的故事板,风格的DataTemplates等在XAML。

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.

这篇关于XAML或者C#代码隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆