当添加组件类VS用户控制? [英] When to add a Component Class vs User Control?
问题描述
我有一个总体思路,并有一些明显的情况下,但也有给我一些灰色地带 - 什么时候最好使用从一个组件延伸,当它是最好创建一个用户控件?这涉及到一个具体的工作问题,我试图解决,但认为细节并不重要 - 一般这个问题的答案是足以让我。
I have a general idea, and there are some obvious cases, but there are also some gray areas for me - when is it best to use to extend from a component and when is it best to create a user control? This pertains to a specific work problem I am trying to solve, but the specifics of that are not important - a general answer to this question is enough for me.
推荐答案
在WPF和Windows Forms,两者的主要区别是,用户控件,就是要控件的集合 - 一个可重复使用,单个对象来自多个控件的自己组成的
In WPF and Windows Forms, both, the main difference is that a UserControl is meant to be a collection of controls - a reusable, single object "composed" from multiple controls themselves.
您会impelemnt而不是用户控件组件/ CustomControl /控制,如果你正在一个单一的,基本控制与新的行为,而不是打控制那小组成的控制。组件通常是一个非视觉行为,其中一个CustomControl /控制通常为视觉控制
You'd impelemnt a Component/CustomControl/Control instead of a UserControl if you are making a single, primitive control with new behavior, instead of making a "control" that's composed of smaller controls. Component usually is a non-visual behavior, where a CustomControl/Control is usually for a visual control.
这篇关于当添加组件类VS用户控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!