2011-12-28 2 views
2
내가 여기 DragDropHelper와 솔루션 을 제안 베아 Stollnitz http://bea.stollnitz에서이 링크를 발견

MVVM는 더 adorners

를 사용하여 WPF에 대한 몇 가지 드래그 & 드롭을 만들려고

이 없습니다 요소에 adorners에 액세스 할 수 없습니다. co.kr에서/파일// DragDropListBox.zip

(46)하지만 난 일부 이벤트는 DataTemplate을에서 버튼이나 라디오 버튼 같은 구성 요소를 생성하여 그것을 사용자 정의 할 때, 내가 드래그 & 드롭이 오류가

"에 adorners에 액세스 할 수 없습니다 저 요소 꾸미는 사람이 없다. " 이 광고

this.adornerLayer.Update (this.AdornedElement)에

;

당신이 bea.stollnitz.com/files/46/DragDropListBox.zip

를 다운로드 및 라디오 버튼에 추가

<DataTemplate x:Key="pictureTemplate"> 
     <DataTemplate.Resources> 
      <Style TargetType="Image"> 
       <Setter Property="Width" Value="50" /> 
       <Setter Property="Height" Value="50" /> 
       <Setter Property="Margin" Value="10" /> 
      </Style> 
     </DataTemplate.Resources> 
     <Grid> 
      <Image Source="{Binding Path=Location}" /> 
      <RadioButton /> 
     </Grid> 
    </DataTemplate> 

예에 의해

<DataTemplate x:Key="pictureTemplate"> 
     <DataTemplate.Resources> 
      <Style TargetType="Image"> 
       <Setter Property="Width" Value="50" /> 
       <Setter Property="Height" Value="50" /> 
       <Setter Property="Margin" Value="10" /> 
      </Style> 
     </DataTemplate.Resources> 
      <Image Source="{Binding Path=Location}" /> 
    </DataTemplate> 

을 대체하여 쉽게 재현 할 수

템플릿

나는 이미 링크를 찾았지만 그들 중 아무도 cle 이 문제를 해결하는 방법.

이 코드

VisualCollection을 visualChildren을 추가 제안

No events passed to WPF adorner layer

; FrameworkElement @object;

public CustomAdorner(UIElement adornedElement) : 
    base(adornedElement) 
{ 
    visualChildren = new VisualCollection(this); 
    @object = new Button {Content = "prova"}; 
    visualChildren.Add(@object); 
} 
protected override Visual GetVisualChild(int index) 
{ 
    return visualChildren[index]; 
} 

하지만 난이 링크 닷넷 4 문제에 대해

private bool IsItemDisconnected(object item) 
{ 
    bool isDisconnected = false; 

    var itemType = item.GetType(); 
    if (itemType.FullName.Equals("MS.Internal.NamedObject")) 
    { 
    isDisconnected = true; 
    } 

    return isDisconnected; 
} 

이 마지막 링크 토론을 제안

http://social.msdn.microsoft.com/Forums/en/wpf/thread/e6643abc-4457-44aa-a3ee-dd389c88bd86?prof=required

위해와 같은 일을 추가 할 경우 확신 그러나 나는 또한 버그를 가지고있다.

+0

아무도 내 질문에서 영감을받지 못한 것 같습니다. 나는 비올 스톨 니츠 솔루션의 또 다른 구현을 찾는다. http://www.codeproject.com/KB/WPF/gong-wpf-dragdrop.aspx를 사용하여, 마침내 드래그 앤 드롭으로 이벤트 생성 템플릿을 만들었습니다. 이 솔루션은 실제 mvvm보다는 코드 뒤의 코드처럼 보이지만 (뷰 모델에서 드래그 오버 및 드롭 이벤트로 직접 관리하기 때문에) 버그없이 작동하고 또 다른 장점이 있습니다. 드롭 된 항목을 정렬 할 수 있습니다. – Pansoul

+0

혹시 이것에 대한 해결책을 찾았습니까? 동일한 코드를 생각하면 같은 문제가 발생합니다. –

답변