0

내 컨트롤에 VS2010 (또는 그 문제의 경우 VS2008)에 스마트 태그를 추가하면 VS 충돌이 발생합니다.Visual Studio의 스마트 태그 (일명 ActionList) 충돌

internal class DataEditorDesigner : ComponentDesigner { 
[...] 
    public override DesignerActionListCollection ActionLists { 
     get { 
      var lists = new DesignerActionListCollection(); 
      lists.AddRange(base.ActionLists); 
      lists.Add(new DataEditorActionList(Component)); 
      return lists; 
     } 
    } 
} 

internal class DataEditorActionList : DesignerActionList { 
    public DataEditorActionList(IComponent component) : base(component) {} 
    public override DesignerActionItemCollection GetSortedActionItems() { 
     var items = new DesignerActionItemCollection(); 
     items.Add(new DesignerActionPropertyItem("DataSource", "Data Source:", "Data")); 
     items.Add(new DesignerActionMethodItem(this, "AddControl", "Add column...")); 
     return items; 
    } 
    private void AddControl() { 
     System.Windows.Forms.MessageBox.Show("dpa"); 
    } 
} 

데이터 소스 속성이 같은 선언 : 그것을 디버깅하는 방법에 대한

[AttributeProvider(typeof (IListSource))] 
    [DefaultValue(null)] 
    public object DataSource { 
[...] 

어떤 아이디어

다음 디자이너는 작업 목록에 사용?

+0

스마트 태그가 매우 스마트하지 않습니다. –

+0

http://connect.microsoft.com/의 Microsoft Connect에이 문제를 제출하십시오. 아마도이 문제는 이미 알려져 있으며 해결 방법이있을 수 있습니다. –

답변

0

해결책을 찾았습니다. DesignerActionList 클래스에 래퍼 속성을 추가해야합니다. 실제로는 실제 구성 요소가 아니라 해당 위치에서 읽습니다.

internal static PropertyDescriptor GetPropertyDescriptor(IComponent component, string propertyName) { 
    return TypeDescriptor.GetProperties(component)[propertyName]; 
} 

internal static IDesignerHost GetDesignerHost(IComponent component) { 
    return (IDesignerHost) component.Site.GetService(typeof (IDesignerHost)); 
} 

internal static IComponentChangeService GetChangeService(IComponent component) { 
    return (IComponentChangeService) component.Site.GetService(typeof (IComponentChangeService)); 
} 

internal static void SetValue(IComponent component, string propertyName, object value) { 
    PropertyDescriptor propertyDescriptor = GetPropertyDescriptor(component, propertyName); 
    IComponentChangeService svc = GetChangeService(component); 
    IDesignerHost host = GetDesignerHost(component); 
    DesignerTransaction txn = host.CreateTransaction(); 
    try { 
     svc.OnComponentChanging(component, propertyDescriptor); 
     propertyDescriptor.SetValue(component, value); 
     svc.OnComponentChanged(component, propertyDescriptor, null, null); 
     txn.Commit(); 
     txn = null; 
    } finally { 
     if (txn != null) 
      txn.Cancel(); 
    } 
} 

다음을 사용 : 또한, 같은 코드를 작성하는 것이 필요

[AttributeProvider(typeof (IListSource))] 
public object DataSource { 
    get { return Editor.DataSource; } 
    set { DesignerUtil.SetValue(Component, "DataSource", value); } 
} 

등 다른 속성.