Custom Control in WPF as necessary as in Winforms?

て烟熏妆下的殇ゞ 提交于 2019-12-06 22:27:28

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

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).

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

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

  2. 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.

  3. 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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!