根据需要在自定义的WinForms控制WPF? [英] Custom Control in WPF as necessary as in Winforms?

查看:133
本文介绍了根据需要在自定义的WinForms控制WPF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在接受记者采访时,该公司是问我在使用WPF自定义控件。我与所有的创建一个控件(DataTemplate中,控制模板,样式,触发器等)的WPF一路电源的发现,有编写覆盖的OnRender方法真的没有必要了一个自定义的控制。后来发现,大部分的发展已经在的WinForms。

During an interview, the company was asking about my use of custom controls in WPF. I have found with all of the power of the WPF way of creating a control (datatemplate, control template, styles,triggers etc... ) that having to write a custom control that overrides the OnRender method really hasn't been necessary. Later found out that most of their development has been in Winforms.

如果从100%的WPF方向的控制来了,怎么常常是有必要写用的OnRender覆盖一个customcontrol?在WinForm的方法是真的不利用创建控件的WPF组成技术,它好像不是基于多WPF知识的问题。

If coming at a control from a 100% WPF direction, how often is it necessary to write a customcontrol with OnRender overrides? The Winform approach is really not making use of the WPF composition technique of creating controls and it seemed like a question not based on much WPF knowledge.

由于
哈罗德

推荐答案

好问题(虽然有点意见为主),并没有答案?固定。

Good question (though a bit opinion-based) and no answers? Fixing.

如果你的WinForms经验的开发人员,然后想着WinForm的路依然在WPF可以接受的。一段时间。在这里,你会发现自我决策大多自定义控件(含XAML和代码,甚至没有XAML)。但你学习的越少,您需要。很多很多任务都可以在WPF可以完成,只是因为它是非常灵活的。每个实体包含的东西有什么可定制:模板,样式,转换器,行为甚至普通的事件处理

If you are winforms-experienced developer, then thinking winform-way is still acceptable in wpf. For a while. This is where you may find self making mostly custom controls (containing xaml and code, or even without xaml). But the more you learn, the less you need that. Many many tasks can be completed in wpf simply because it is very flexibly. Every entity consist of something what can be customized: templates, styles, converters, behaviors or even plain event handling.

您可以用自定义的控制开始,然后找出你并不真的需要它(或者也可以降级为简单的改型)。

You can start with custom control and then find out what you don't really need it (or it can be downgraded to simple restyling).

当我开始做第一次严重的WPF项目,有3个自定义的控制和他们仍然。这是为什么。

When I started making first serious wpf project, there were 3 custom controls and they are still. Here is why.


  1. 轮廓的TextBlock。很简单,因为你需要自定义的OnRender (建立和绘制几何轮廓)。

  1. Outlined TextBlock. Simply because you need custom OnRender (to build and draw geometry for outline).

动画内容。要改变内容时应用过渡动画。我几乎可以使它没有自定义控件,但有一个问题 - 过渡左到右,当计算动画逻辑,从右到左,上下或向下的。这是waaaay容易有一个自定义的控制。但可能与用户控件和看法,而不是漂亮的不动。

Animated content. To apply transition animation when changing content. I could almost make it without custom control, but there is a problem - calculating animations logic when transitioning left-to-right, right-to-left, up-down or down-up. It's waaaay easy to have in one custom control. But possible with UserControl and view, not as pretty still.

图。很简单,因为它太复杂与视觉键,因为使用性能的GDI +提供了数百万个点(hundered数千数字)为毫秒内绘制<提交/ code>

Graph. Simply because it's too complicated to be presented with Visual and because of performance using gdi+ gives millions of points (hundered thousands figures) to be drawn within ms.

结论:这是很好的和有用的,但路不到它在的WinForms(在那里你根本就其他选项)。

Conclusion: it's good and useful, though way less than it was in winforms (where you simply had no other option).

这篇关于根据需要在自定义的WinForms控制WPF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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