This is a migrated thread and some comments may be shown as answers.

Make one tile Fixed in place / not moveable

1 Answer 105 Views
TileView
This is a migrated thread and some comments may be shown as answers.
jen
Top achievements
Rank 1
jen asked on 11 May 2017, 07:32 PM
In my tileview I want the user to be able to rearrange any of the tiles except for the very first tile. How can I achieve this?

Is there any sort of property on the tile that can prevent the tile from moving?

 

My tiles Position property is bound to a property in the entity the tile represents. I have tried putting logic in the property set to prevent changes if the position is 0, but that is preventing ANY of the tiles from changing position

 

    <Style TargetType="{x:Type telerik:RadTileViewItem}">
        <Setter Property="Position" Value="{Binding Path=DisplayIndex, Mode=TwoWay}" />
    </Style>

    public int DisplayIndex
    {
        get { return DisplayIndex; }
        set
        {
            if (m_DisplayIndex !=0 && value != DisplayIndex && value > 0)
            {
                m_DisplayIndex = value;
            }
            NotifyPropertyChanged("DisplayIndex");
        }
    }

 

Any ideas or insight? thanks!

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 16 May 2017, 11:37 AM
Hello,

If you want to prevent the first tile view item from moving you can subscribe to the PreviewTileDragStarted and PreviewTilePositionChanged events of the RadTileView control. In the events handlers, you can check if the current item has Position 0 (for example) and handle the events.
<telerik:RadTileView PreviewTileDragStarted="tileView_PreviewTileDragStarted"
                     PreviewTilePositionChanged="tileView_TilePositionChanged"/>
private void tileView_PreviewTileDragStarted(object sender, TileViewDragEventArgs e)
{
    var item = e.DraggedItem as RadTileViewItem;
    if (item.Position == 0)
    {
        e.Handled = true;
    }
}
 
private void tileView_TilePositionChanged(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    var item = e.OriginalSource as RadTileViewItem;
    if (item.Position == 0)
    {
        e.Handled = true;
    }
}

For your convenience, we have created sample project demonstrating this approach. Give it a try and let us know if it works for you. 

Regards,
Dinko
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
TileView
Asked by
jen
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or