【问题标题】:WPF inherited UserControl lost VS designer supportWPF 继承的 UserControl 失去了 VS 设计器的支持
【发布时间】:2010-04-26 09:51:16
【问题描述】:

我写了这个 UserControl:

<my:MyUserControl x:Class="MyClass"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"             
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:my="clr-namespace:MyNameSpace.MyControls;assembly=MyAssembly">
 </my:MyUserControl>

 public partial class Editor : MyNameSpace.MyControls.MyUserControl {}

一切正常,控件显示在 VS 2008 设计器中,但我无法像使用 UserControl 一样直接单击元素并选择它们。

知道怎么解决吗?

【问题讨论】:

    标签: wpf visual-studio-2008 inheritance designer


    【解决方案1】:

    现在我知道为什么会这样了。

    确实有效,但我的基类实现了IComponent 接口,这是失去设计器支持的原因。

    public class BaseClass: System.Windows.Controls.UserControl, System.ComponentModel.IComponent
    {}
    

    如果我删除界面,它会再次起作用!

    【讨论】:

      猜你喜欢
      • 2010-10-27
      • 2010-09-21
      • 1970-01-01
      • 2016-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多