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 窗体中,主要区别在于 UserControl 是控件的集合 - 一个可重用的单个对象组合"自多个控件本身.
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.
如果您正在制作具有新行为的单个原始控件,而不是制作由较小控件组成的控件",那么您将实施 Component/CustomControl/Control 而不是 UserControl.组件通常是一种非可视化的行为,其中一个CustomControl/Control通常是一个可视化的控件.
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.
这篇关于何时添加组件类与用户控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:何时添加组件类与用户控件?
基础教程推荐
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 如何激活MC67中的红灯 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01