2011-03-21 5 views
0

모든 데이터를 RadTreeView에 바인딩했지만 드래그 앤 드롭을 사용할 수 없습니다. 나는 4 가지 특성을radtreeview에서 드래그 드롭을 사용할 수 없습니다

IsDragDropEnabled="True" 
IsDropPreviewLineEnabled="True" 
AllowDrop="True" 
IsDragPreviewEnabled="True" 

으로 사용했으며 동일한 트리 내에 항목을 드롭하려고합니다. 그러나 그것은 작동하지 않습니다.

+0

더 많은 관련 정보를 제공해 주시겠습니까? –

답변

1

this telerik article을 빨리 읽은 후 끌어서 놓기가 제대로 작동하는 것 같습니다.

<telerik:RadTreeView ... EnableDragAndDrop="true" OnNodeDrop="MyTreeView_NodeDrop"> 

는 EnableDragAndDrop 및 OnNodeDrop 작동을 얻기에 두 개의 중요한 조각을 것 같다,하지만 당신은 시도 속성 목록에 없었다. HTH 이제

뒤에 코드에서 당신은

this.treeView1.AddHandler(RadDragAndDropManager.DropQueryEvent, new EventHandler<DragDropQueryEventArgs>(OnDropQuery), true); 

이가 그런

private void OnDropQuery(object sender, DragDropQueryEventArgs e) 
    { 
     RadTreeViewItem destinationItem = e.Options.Destination as RadTreeViewItem; 
     object source = this.GetItemFromPayload<object>(e.Options.Payload); 
     object target = destinationItem != null ? destinationItem.Item : null; 
     DropPosition position = destinationItem != null ? destinationItem.DropPosition : DropPosition.Inside; 

     if (source != null && target != null) 
     { 
      Section sourceSection = source as Section; 
      Section targetSection = target as Section; 
      Question sourceQuestion = source as Question; 
      Question targetQuestion = target as Question; 

      if (sourceQuestion != null) 
      { 
       try 
       { 

        if (sourceQuestion != null && targetQuestion != null && object.ReferenceEquals(sourceQuestion, targetQuestion)) 
        { 
         sourceSection.Questions.Remove(sourceQuestion); 
         targetSection.Questions.Add(sourceQuestion); 
         e.QueryResult = false; 
         return; 
        } 

        if (targetQuestion != null && position == DropPosition.Inside) 
        { 
         sourceSection.Questions.Remove(sourceQuestion); 
         targetSection.Questions.Add(sourceQuestion); 
         e.QueryResult = false; 
         return; 
        } 

        if (position != DropPosition.Inside && targetQuestion == null) 
        { 
         sourceSection.Questions.Remove(sourceQuestion); 
         targetSection.Questions.Add(sourceQuestion); 
         e.QueryResult = false; 
         return; 
        } 
       } 
       catch (Exception ex) 
       { 


       } 
      } 
     } 
     else 
     { 
      e.QueryResult = false; 
      return; 
     } 
     e.QueryResult = true; 

    } 

이다 생성자

에서 이벤트를

를 해고해야

1
<telerik:RadTreeView x:Name="treeView1" IsDragDropEnabled="True" Margin="2,0,0,0" ItemsSource="{Binding SelectedSectionList, Mode=TwoWay}" ItemTemplate="{StaticResource SectionTemplate}" IsEditable="True" SelectedItem="{Binding SelectedCustomSectionList, Mode=TwoWay}" Grid.Column="2"> 

. 드래그 앤 드롭 할 수 있습니다.

관련 문제