簡體   English   中英

Visual Studio使用UserControlDesigner而不是CustomDesigner

[英]Visual Studio uses UserControlDesigner instead of CustomDesigner

我有一個ASP-UserControl QuestionWithAnswer (.ascx) : BaseQuestion : UserControl和ControlDesigner QuestionDesigner : UserControlDesigner 現在,我使用DesignerAttribute來關聯控件和設計器:

[Designer(typeof(QuestionDesigner))]
public class BaseQuestion : UserControl

所有類型都在同一程序集中(WEB應用程序)。 但是它仍然加載UserControlDesigner而不是我的。 我是否必須將設計師安排在單獨的組裝中? 我想ASP頁設計器找不到設計器。

謝謝!


演示代碼:

public class FragenDesigner : UserControlDesigner
{
    private DesignerActionList _actionList;
    private DesignerVerb[] _verbs;

    public override DesignerActionListCollection ActionLists
    {
        get
        {
            if (_actionList == null)
            {
                _actionList = new DesignerActionList(new System.Windows.Forms.TextBox());
                _actionList.AutoShow = true;


                ActionLists.Add(_actionList);
            }
            return base.ActionLists;
        }
    }

    public override DesignerVerbCollection Verbs
    {
        get
        {
            if (_verbs == null)
            {
                _verbs = new DesignerVerb[]
                         {
                             new DesignerVerb("test", onblabla), 
                         };

                Verbs.AddRange(_verbs);
            }

            return base.Verbs;
        }
    }

    private void onblabla(object sender, EventArgs e)
    {
        MessageBox.Show("blabla");
    }
}

好的,已經有了答案: http : //msdn.microsoft.com/zh-cn/library/system.web.ui.design.usercontroldesigner.aspx

備注

從UserControlDesigner派生自己的設計器沒有開發者優勢。 若要增強自定義控件的設計時體驗,請從CompositeControl派生您的控件,並從CompositeControlDesigner派生您的設計器。 在這種情況下,您將不會在ASP.NET標記中使用.ascx文件。

就我而言,不可能更改為CompositeControls。 相信我,我更喜歡Composite / WebControls ...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM