2012-12-28 1 views
3
나는 s:SurfaceDragDrop 이벤트와 SurfaceListBox에 객체 ( ScatterViewItem를) 포기하고있어

에 떨어졌다 때 SurfaceListBoxItem 및 ScatterViewItem 가져 오기를 전체 SurfaceListBox에 낙하를 감지 할 때 그것을 잘 작동합니다 SurfaceListBoxItem 개체가 삭제 된 것을 알고 싶습니다.나는, 그러나, 객체가 SurfaceListBox 및 ScatterView

또한 ScatterView에 대해이 작업을 수행하려고합니다. 즉 ScatterView 중 어느 객체가 누락되었는지 감지하는 중입니다.

내 코드는 다음과 같은 것입니다 :

<s:SurfaceListBox 
    x:Name="listBoxList" 
    Background="{x:Null}" 
    AllowDrop="True" 
    s:SurfaceDragDrop.Drop="ListBox_Drop" > 
</s:SurfaceListBox> 

<s:ScatterView 
    x:Name="scatterList" 
    Background="{x:Null}" 
    AllowDrop="True" 
    s:SurfaceDragDrop.Drop="Scatter_Drop" > 
</s:ScatterView> 

그리고 내 항목을 추가 :

listBoxList.Items.Add("ListBox Item 1"); 
listBoxList.Items.Add("ListBox Item 1"); 
listBoxList.Items.Add("ListBox Item 1"); 

scatterList.Items.Add("ScatterViewItem A"); 
scatterList.Items.Add("ScatterViewItem B"); 
scatterList.Items.Add("ScatterViewItem C"); 

그래서 내가 어떻게 ListBox_DropScatter_Drop에 항목을 얻을 수 있나요?

편집

로버트 응답을 통해 나는 내 문제를 해결하기 위해 관리. 그래서 결과 코드합니다 (ScatterView에 대한)이 같은 것입니다 :

<s:ScatterView 
    x:Name="scatterList" 
    Background="{x:Null}"> 
    <s:ScatterView.ItemContainerStyle> 
     <Style TargetType="s:ScatterViewItem"> 
      <EventSetter Event="s:SurfaceDragDrop.Drop" Handler="Scatter_Drop"/> 
      <Setter Property="AllowDrop" Value="True" /> 
     </Style> 
    </s:ScatterView.ItemContainerStyle> 
</s:ScatterView> 

와의 SurfaceListBox :

당신은 AllowDrop를 설정하고 각 ScatterViewItem 대한 드롭 이벤트 핸들러를 연결해야
<s:SurfaceListBox 
    x:Name="listBoxList" 
    Background="{x:Null}"> 
    <s:SurfaceListBox.ItemContainerStyle> 
     <Style TargetType="s:SurfaceListBox"> 
      <EventSetter Event="s:SurfaceDragDrop.Drop" Handler="ListBox_Drop"/> 
      <Setter Property="AllowDrop" Value="True" /> 
     </Style> 
    </s:SurfaceListBox.ItemContainerStyle> 
</s:SurfaceListBox> 

답변

1

& ListBoxItem. 그런 다음 이벤트 소스가 드롭 된 항목이됩니다.

+0

에 반대하지만, 그것을 할 수있는 적절한 방법을 보이지 않는. 50 개 항목이 있다면 나는 50 개 항목이 아닌 하나의 드롭 이벤트를 가져야합니다. 여기에 뭔가 빠져 있다면 저에게 계몽하십시오. –

+1

모든 항목을 정확히 동일한 이벤트 처리기 기능을 가리 키도록 할 수 있지만 각 항목에는 AllowDrop이 직접 설정되어 있어야합니다. –

+0

로버트에게 정보를 제공해 주셔서 감사 드리며 해결책은 첫 번째 게시물에 있습니다. –

1

작은 수정 나는 위의 해결책을 생각합니다.

<Style TargetType="s:SurfaceListBoxItem"> 

작업을 수행
<Style TargetType="s:SurfaceListBox"> 
+0

이것은 주석이어야합니다. – Mateusz

+0

댓글 올리는 방법을 잘 모름 ... – PotatoJam

관련 문제