I'm confused, can anyone help me out?
我很困惑,任何人都可以帮助我吗?
Edit
编辑
My problem is that I have created an ActiveX control in Delphi and I just can't get it to play nicely in WPF land. I have looked at the relevant MSDN pages, and it looks like it SHOULD work, so I may have gone wrong in the way that I have created the ActiveX control in the first place.
我的问题是我在Delphi中创建了一个ActiveX控件,我无法让它在WPF中很好地发挥作用。我查看了相关的MSDN页面,看起来它应该工作,所以我可能在创建ActiveX控件的方式上出错了。
See Hosting ActiveX control in WPF
请参阅WPF中的托管ActiveX控件
6 个解决方案
#1
5
Have a look at the official documentation for both classes
看看这两个课程的官方文档
Here is the Class signature for System.Windows.Controls.control class
这是System.Windows.Controls.control类的Class签名
public class Control : FrameworkElement
Here is the Class signature for System.Windows.Forms.Control class
这是System.Windows.Forms.Control类的Class签名
public class Control : Component, IOleControl,
IOleObject, IOleInPlaceObject, IOleInPlaceActiveObject, IOleWindow, IViewObject,
IViewObject2, IPersist, IPersistStreamInit, IPersistPropertyBag, IPersistStorage,
IQuickActivate, ISupportOleDropSource, IDropTarget, ISynchronizeInvoke, IWin32Window,
IArrangedElement, IBindableComponent, IComponent, IDisposable
#2
12
They are controls that live in completely different worlds.
它们是生活在完全不同的世界中的控制。
System.Windows.Controls.Control
is a WPF control.
System.Windows.Controls.Control是一个WPF控件。
System.Windows.Forms.Control
is a WinForms control.
System.Windows.Forms.Control是一个WinForms控件。
The choice is pretty simple. If you are developing a WinForms app - use WinForms controls. Similarly, if you are writing a WPF app - use WPF controls.
选择很简单。如果您正在开发WinForms应用程序 - 使用WinForms控件。同样,如果您正在编写WPF应用程序 - 请使用WPF控件。
As for choosing between WPF and WinForms - this question might help.
至于在WPF和WinForms之间进行选择 - 这个问题可能有所帮助。
#3
1
System.Windows.Controls.Control
is for WPF application
System.Windows.Controls.Control用于WPF应用程序
System.Windows.Forms.Control
i s for Winforms application.
System.Windows.Forms.Control我是Winforms应用程序。
#4
0
System.Windows.Forms.Control
Defines the base class for controls, which are components with visual representation.
System.Windows.Forms.Control定义控件的基类,控件是具有可视表示的组件。
System.Windows.Controls.Control
Represents the base class for user interface (UI) elements that use a ControlTemplate to define their appearance.
System.Windows.Controls.Control表示使用ControlTemplate定义其外观的用户界面(UI)元素的基类。
#5
0
What is Windows Presentation Foundation and Windows Forms?
什么是Windows Presentation Foundation和Windows窗体?
You should be able to determine that from the namespace that one is the base Control class for WPF (all WPF uses the .Windows naming) and the other is for Windows Forms.
您应该能够从命名空间确定一个是WPF的基本Control类(所有WPF使用.Windows命名),另一个是Windows Forms。
Can you clarify what exactly you find confusing? I will update my answer.
你能澄清一下你究竟发现什么令人困惑吗?我会更新我的答案。
HTH,
HTH,
Useful links
- Windows Forms Controls and Equivalent WPF Controls
- System.Windows.Forms
- System.Windows.Controls
有用的链接 - Windows窗体控件和等效的WPF控件 - System.Windows.Forms - System.Windows.Controls
#6
0
I think there are a number of differences but the first one that jumps to mind is that System.Windows.Controls.Control
uses a template to define the visual aspects of the control, without a template it has no visual aspect at all. In other words without defining that template you cannot focus it to become visible or show it in your application, because there is literally no visual definition for it.
我认为有许多不同之处,但第一个跳出来的是System.Windows.Controls.Control使用模板来定义控件的可视方面,没有模板它根本没有视觉方面。换句话说,如果没有定义该模板,则无法将其聚焦为可见或在应用程序中显示它,因为它实际上没有可视化定义。
On the other hand you have a System.Windows.Forms.Control
which allows you to create a control that inherits from a UserControl, control class, or other Windows Control. If you don't specify a new visual setting for your control it will display according to what the parent control you inherited from was set to display.
另一方面,您有一个System.Windows.Forms.Control,它允许您创建一个继承自UserControl,控件类或其他Windows控件的控件。如果没有为控件指定新的可视化设置,它将根据您继承的父控件设置为显示的内容显示。
So, with System.Windows.Controls.Control
you get a lot more flexibility as the cost of additional work, and with System.Windows.Forms.Control
you get to inherit from existing controls, saving time, as the cost of less flexibility.
因此,使用System.Windows.Controls.Control可以获得更多的灵活性,因为额外的工作成本,并且使用System.Windows.Forms.Control可以从现有控件继承,从而节省时间,因为灵活性较低。
#1
5
Have a look at the official documentation for both classes
看看这两个课程的官方文档
Here is the Class signature for System.Windows.Controls.control class
这是System.Windows.Controls.control类的Class签名
public class Control : FrameworkElement
Here is the Class signature for System.Windows.Forms.Control class
这是System.Windows.Forms.Control类的Class签名
public class Control : Component, IOleControl,
IOleObject, IOleInPlaceObject, IOleInPlaceActiveObject, IOleWindow, IViewObject,
IViewObject2, IPersist, IPersistStreamInit, IPersistPropertyBag, IPersistStorage,
IQuickActivate, ISupportOleDropSource, IDropTarget, ISynchronizeInvoke, IWin32Window,
IArrangedElement, IBindableComponent, IComponent, IDisposable
#2
12
They are controls that live in completely different worlds.
它们是生活在完全不同的世界中的控制。
System.Windows.Controls.Control
is a WPF control.
System.Windows.Controls.Control是一个WPF控件。
System.Windows.Forms.Control
is a WinForms control.
System.Windows.Forms.Control是一个WinForms控件。
The choice is pretty simple. If you are developing a WinForms app - use WinForms controls. Similarly, if you are writing a WPF app - use WPF controls.
选择很简单。如果您正在开发WinForms应用程序 - 使用WinForms控件。同样,如果您正在编写WPF应用程序 - 请使用WPF控件。
As for choosing between WPF and WinForms - this question might help.
至于在WPF和WinForms之间进行选择 - 这个问题可能有所帮助。
#3
1
System.Windows.Controls.Control
is for WPF application
System.Windows.Controls.Control用于WPF应用程序
System.Windows.Forms.Control
i s for Winforms application.
System.Windows.Forms.Control我是Winforms应用程序。
#4
0
System.Windows.Forms.Control
Defines the base class for controls, which are components with visual representation.
System.Windows.Forms.Control定义控件的基类,控件是具有可视表示的组件。
System.Windows.Controls.Control
Represents the base class for user interface (UI) elements that use a ControlTemplate to define their appearance.
System.Windows.Controls.Control表示使用ControlTemplate定义其外观的用户界面(UI)元素的基类。
#5
0
What is Windows Presentation Foundation and Windows Forms?
什么是Windows Presentation Foundation和Windows窗体?
You should be able to determine that from the namespace that one is the base Control class for WPF (all WPF uses the .Windows naming) and the other is for Windows Forms.
您应该能够从命名空间确定一个是WPF的基本Control类(所有WPF使用.Windows命名),另一个是Windows Forms。
Can you clarify what exactly you find confusing? I will update my answer.
你能澄清一下你究竟发现什么令人困惑吗?我会更新我的答案。
HTH,
HTH,
Useful links
- Windows Forms Controls and Equivalent WPF Controls
- System.Windows.Forms
- System.Windows.Controls
有用的链接 - Windows窗体控件和等效的WPF控件 - System.Windows.Forms - System.Windows.Controls
#6
0
I think there are a number of differences but the first one that jumps to mind is that System.Windows.Controls.Control
uses a template to define the visual aspects of the control, without a template it has no visual aspect at all. In other words without defining that template you cannot focus it to become visible or show it in your application, because there is literally no visual definition for it.
我认为有许多不同之处,但第一个跳出来的是System.Windows.Controls.Control使用模板来定义控件的可视方面,没有模板它根本没有视觉方面。换句话说,如果没有定义该模板,则无法将其聚焦为可见或在应用程序中显示它,因为它实际上没有可视化定义。
On the other hand you have a System.Windows.Forms.Control
which allows you to create a control that inherits from a UserControl, control class, or other Windows Control. If you don't specify a new visual setting for your control it will display according to what the parent control you inherited from was set to display.
另一方面,您有一个System.Windows.Forms.Control,它允许您创建一个继承自UserControl,控件类或其他Windows控件的控件。如果没有为控件指定新的可视化设置,它将根据您继承的父控件设置为显示的内容显示。
So, with System.Windows.Controls.Control
you get a lot more flexibility as the cost of additional work, and with System.Windows.Forms.Control
you get to inherit from existing controls, saving time, as the cost of less flexibility.
因此,使用System.Windows.Controls.Control可以获得更多的灵活性,因为额外的工作成本,并且使用System.Windows.Forms.Control可以从现有控件继承,从而节省时间,因为灵活性较低。