Drag and Drop problem with TileView

7 posts, 0 answers
  1. parag patel
    parag patel avatar
    12 posts
    Member since:
    Oct 2009

    Posted 22 Oct 2009 Link to this post

    Hi,

    I am trying to make user control in wpf where I have to drag and drop a item from RadPanelBar to RadTileView and vise versa. 
    I am using telerik RadDragandDropManager class for drag and drop
    i have set allowDrag and allowDrop property radpanelbar ,radpanelaritem, radtileview,radtileviewitem.

    I am able to drag an item from tileview to panelbar It is working fine.

    But when I drag an item for panelbar to tile view I get a null reference exception. This exception comes from radtileview control code file.

    Now form my analysis I came to know that radtileview does not allow  to drag any item on it through RadDragandDropManager.

    If you can provide me any example for this
  2. Tihomir Petkov
    Admin
    Tihomir Petkov avatar
    576 posts

    Posted 22 Oct 2009 Link to this post

    Hi Parag,

    There is a known bug in the Beta version of RadTileView which affects drag and drop scenarios. The issue will be resolved in the upcoming Q3 release which is due in the beginning of November.

    Greetings,
    Tihomir Petkov
    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. dimiter
    dimiter avatar
    6 posts
    Member since:
    Apr 2007

    Posted 14 Dec 2009 Link to this post

    Hi

    I want to drag and drop Item in Tile view but drop events doesn't raise could you send me an example how to drop in Tile view 
    Thanks in advance

    greeting
  5. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 17 Dec 2009 Link to this post

    Hello Dimiter,

    Please find attached a sample project that demonstrates drag&drop functionality between a list box and a tile view. Let me know if you find something unclear.


    Greetings,
    Kiril Stanoev
    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.
  6. Aleksey
    Aleksey avatar
    6 posts
    Member since:
    Apr 2014

    Posted 21 Apr 2014 Link to this post

    Hello, I have a problem with the cancell operation DragAndDrop in my RadTileView control. I Have some RadTileViewItem, which have the property AllowDrop=false, but i can still drop my RadTileViewItem on them.
    Example: 
    <telerik:RadTileView Grid.Row="1" ItemsSource="{Binding CommonAssets}" Style="{StaticResource HiddenTitleGrayStyle}" BorderBrush="Transparent" 
                                 MinimizedColumnWidth="480" MinimizedRowHeight="325" RowHeight="325" ColumnsCount="3" MaximizeMode="Zero" 
                                 ContentTemplate="{StaticResource MeasureItem}" HeaderStyle="{StaticResource GrayTileViewItemStarStyle}" ItemContainerStyle="{StaticResource ReordableItemStyle}">
                <telerik:RadTileView.Resources>
                    <DataTemplate DataType="{x:Type pMe:ProtectiveMeasuresAssetVM}"/>
                </telerik:RadTileView.Resources>
                <i:Interaction.Behaviors>
                    <behaviors:RadTilesDragDropBehavior/>
                </i:Interaction.Behaviors>
            </telerik:RadTileView>
    In RadTilesDragDropBehavior.cs:

     protected override void OnAttached()
            {
                base.OnAttached();
                DragDropManager.AddDragInitializeHandler(AssociatedObject, OnDragInitialize);
             }
    private void OnDragInitialize(object sender, DragInitializeEventArgs args)
            {
                var tileView = sender as RadTileView;
                draggingTile = args.OriginalSource as RadTileViewItem;
                foreach (var item in tileView.ChildrenOfType<RadTileViewItem>())
                {
                    if (((ProtectiveMeasuresAssetVM)item.DataContext).IsTop != ((ProtectiveMeasuresAssetVM)draggingTile.DataContext).IsTop)
                        item.AllowDrop = false;
                    else
                        item.AllowDrop = true;
                }
            }


    After that, i can still DragAndDrop all items in my RadTileView 
    Please, help me.


  7. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 22 Apr 2014 Link to this post

    Hello Parag,

    Note that when you set the AllowDrop property on a RadTileViewItem this will prevent the drop only if an element is dropped inside the item. In this case the dragged item is dropped on the RadTileView itself and this is why the AllowDrop property doesn't work.

    In order to prevent the drop on a particular item you can handle the PreviewTilePositionChanged event of the RadTileView.
    <telerik:RadTileView PreviewTilePositionChanged="RadTileView_PreviewTilePositionChanged" />
    ..................
    private void RadTileView_PreviewTilePositionChanged(object sender, Telerik.Windows.RadRoutedEventArgs e)
    {
        RadTileView tileView = (RadTileView)sender;
        var container = e.OriginalSource as RadTileViewItem;
        if (container != null)
        {
            var item = tileView.ItemContainerGenerator.ItemFromContainer(container) as DataItem;
            if (item == null || !item.AllowDrop)
                e.Handled = true;
        }
    }

    You can also take a look at the Pinned Tiles demo. Note that this link leads to our Silverlight demos which share code with the WPF ones. If you prefer you can download the demos for WPF and find this demo there.

    In addition I prepared a sample project which demonstrates this approach. Please give it a try and let me know if it helps.

    Regards,
    Martin
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  8. Aleksey
    Aleksey avatar
    6 posts
    Member since:
    Apr 2014

    Posted 22 Apr 2014 in reply to Martin Link to this post

    Thank you so much. you helped me a lot.=)
Back to Top
UI for WPF is Visual Studio 2017 Ready