开发者

DesignerAttribute in WPF?

Is it possible in WPF to provide an alternate class which should be used as the control to show in the designer instead of the control itself,开发者_如何学C just like DesignerAttribute does for WinForms?

EDIT:

What I'm looking for is what happens with e.g. the ReportViewer class does. This class has an associated class ReportViewerDesigner which is used in the designer instead of the ReportView class itself.


You can manipulate the Metadata Store; since WPF separates the designer metadata into a separate assembly as noted in the MSDN.

In the System.ComponentModel framework, a designer type is associated with its corresponding component through the DesignerAttribute metadata attribute. This means the relationship is established at compile time, forcing a hard-coded dependency between the component's run-time and design-time behavior. To attach a different designer, you must change the DesignerAttribute declaration and recompile the component's code base.

In the WPF Designer, designer metadata is factored into a separate assembly, physically decoupling it from the run-time implementation. This freedom means that different tools can present completely different design experiences for the same run-time type. For more information, see Metadata Store.

A concrete example of this is the VS designer versus the Expression Blend designer.

EDIT:

As noted in the comments section they are fundamentally different approaches. It is not a 1:1 by any means; just as is with a WinForms versus WPF approach to building an application. If you are looking for an elusive attribute which will simply use a differing class as the designer representation; it does not exist. There are certainly ways to achieve what you want and allow the designer to display a given control in a myriad of ways but the approach is not like that of WinForms.

  • How To: Use the Metadata Store
  • WPF Designer Extensibility Architecture (look at Designer Instance Creation)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜