Can't use drag and drop on treeview on childwindow ?

3 posts, 1 answers
  1. Ludovic Alcala
    Ludovic Alcala avatar
    24 posts
    Member since:
    Jan 2010

    Posted 13 Jan 2010 Link to this post

    Hello,
    i have a simple childWindow with a treeview and want to have the hability to drag/drop element in.
    But my code who work fine in a main page, doesn't work on ChildWindow, have you an idea ?


    Here my xaml :
    <basics:ChildWindow.Resources> 
            <telerik:ContainerBindingCollection x:Name="Collection"
                <telerik:ContainerBinding PropertyName="DisplayName" Binding="{Binding DisplayName, Mode=TwoWay}" /> 
            </telerik:ContainerBindingCollection> 
            <telerik:HierarchicalDataTemplate x:Key="CategoryTemplate" 
                                           ItemsSource="{Binding ChildProducts}" 
                                           telerik:ContainerBinding.ContainerBindings="{StaticResource Collection}"
                <TextBlock Text="{Binding DisplayName}" Foreground="Black" /> 
            </telerik:HierarchicalDataTemplate> 
        </basics:ChildWindow.Resources> 
     
     
        <Grid x:Name="LayoutRoot" Background="White"
            <StackPanel Margin="0,0,0,28" HorizontalAlignment="Left"
                <TextBlock Height="24" Margin="0,0,0,0" TextWrapping="Wrap" FontWeight="Bold"><Run Text="Glisser les éléments les uns en dessous des autres pour les ordonner"/></TextBlock> 
                <telerikNavigation:RadTreeView x:Name="ReorderList" 
                                                    IsDragPreviewEnabled="True" 
                                                    ItemTemplate="{StaticResource CategoryTemplate}" 
                                                    IsDragTooltipEnabled="true" 
                                                    IsDropPreviewLineEnabled="false"  
                                                    IsDragDropEnabled="True" IsEditable="true" 
                                                    IsTextSearchEnabled="true" Language="fr" IsVirtualizing="true" 
                                                    SelectionMode="Multiple" MaxHeight="400"
                    <telerikNavigation:RadTreeView.ItemEditTemplate> 
                    <DataTemplate> 
                        <StackPanel Orientation="Horizontal"
                            <TextBox Text="{Binding DisplayName, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" /> 
                        </StackPanel> 
                    </DataTemplate> 
                    </telerikNavigation:RadTreeView.ItemEditTemplate> 
                </telerikNavigation:RadTreeView> 
            </StackPanel> 
            <StackPanel Margin="0,0,1,0" Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right"
                <Button x:Name="CancelButton" Content="Annuler les modifications" Click="CancelButton_Click" Width="154" Height="23" HorizontalAlignment="Right" /> 
                <Button x:Name="OKButton" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Content="Enregistrer" Margin="54,0,0,0" /> 
            </StackPanel> 
     
        </Grid> 


    And in my c# :
    public partial class ReorderElements : ChildWindow 
        { 
            public ObservableCollection<ListingProduct> ProductList { getset; } 
            public ReorderElements() 
            { 
                InitializeComponent(); 
                ReorderList.Loaded += new RoutedEventHandler(ReorderList_Loaded); 
                ReorderList.DragEnded += new RadTreeViewDragEndedEventHandler(ReorderList_DragEnded); 
                ReorderList.PreviewDragStarted += new RadTreeViewDragEventHandler(ReorderList_PreviewDragStarted); 
                ReorderList.PreviewDragEnded += new RadTreeViewDragEndedEventHandler(ReorderList_PreviewDragEnded); 
                RadDragAndDropManager.AddDropQueryHandler(ReorderList, OnDropInsideTreeViewDropQuery); 
            } 
     
            void ReorderList_PreviewDragStarted(object sender, RadTreeViewDragEventArgs e) 
            { 
     
            } 
            private void OnDropInsideTreeViewDropQuery(object sender, DragDropQueryEventArgs e) 
            { 
               //Just a debug function (i want to have the hability to check if im on before or after dropposition and not an inside drop position But it never happen... 
                Debug.WriteLine("ok"); 
            } 
            void ReorderList_PreviewDragEnded(object sender, RadTreeViewDragEndedEventArgs e) 
            { 
     
            } 
     
            void ReorderList_DragEnded(object sender, RadTreeViewDragEndedEventArgs e) 
            { 
                 
            } 
     
            void ReorderList_Loaded(object sender, RoutedEventArgs e) 
            { 
               
            } 
     
            protected override void OnOpened() 
            { 
                base.OnOpened(); 
                ReorderList.ItemsSource = ProductList; 
            } 
            private void OKButton_Click(object sender, RoutedEventArgs e) 
            { 
                this.DialogResult = true
            } 
     
            private void CancelButton_Click(object sender, RoutedEventArgs e) 
            { 
                this.DialogResult = false
            } 
        } 


    The childwindow is loaded in front of a gridview which support drag/drop manually, maybe the problem ?
    Any idea ?
    I use the last version of silverlight telerik.

    Thank you :).




  2. Ludovic Alcala
    Ludovic Alcala avatar
    24 posts
    Member since:
    Jan 2010

    Posted 15 Jan 2010 Link to this post

    Why it isn't possible to use it with a childWindow ? I tried with another code samples (treeviewAutoScroll) and modify it to use childwindow and draganddrop is not ok,

    any idea ?

    Thank you.
  3. DevCraft banner
  4. Answer
    Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 15 Jan 2010 Link to this post

    Hello Ludovic Alcala,

    This is because the ChildWidow opens in a popup which is in a separate visual tree than the rest of the application. We keep track of the ones opened by Telerik controls but for controls like the ChildWindow you need to use the ParticipatingVisualRoots property when a drag starts and add all opened child windows there.

    Here is a thread discussing this:

    http://www.telerik.com/community/forums/silverlight/drag-and-drop/drag-amp-drop-works-except-inside-a-popup.aspx

    Hopefully this will work for you,

    Regards,
    Miroslav
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top