何时添加组件类与用户控件?

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.

这篇关于何时添加组件类与用户控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)