How to call the ActivateItemReorderForItem method

3 posts, 0 answers
  1. Sergio
    Sergio avatar
    18 posts
    Member since:
    May 2014

    Posted 27 Jan 2015 Link to this post

    Hello, I'm working with a DataBoundListBox and I can't find a way to get the right RadDataBoundListBoxItem instance to pass to the ActivateItemReorderForItem method. Here is a part of my code.

    This is the DataTemplate for every element inside my ListBox
    <Page.Resources>
            <DataTemplate x:Key="ListBoxItemTemplate">
                <ContentControl Holding="ContentControl_Holding">
                    <Grid>
                        <Grid.Resources>
                            <converters:FolderContentConverter x:Key="FolderConverter"/>
                        </Grid.Resources>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0.2*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid Margin="10">
                            <Canvas Background="{StaticResource PhoneAccentBrush}"/>
                            <Image Source="/Assets/MainUI/folder.png"/>
                        </Grid>
                        <StackPanel Grid.Column="1">
                            <TextBlock Text="{Binding Name}"
                                VerticalAlignment="Center"
                                FontSize="25"
                                FontWeight="SemiLight"/>
                            <TextBlock Text="{Binding FolderContent, Converter={StaticResource FolderConverter}}"
                                VerticalAlignment="Center"
                                Foreground="#FFA0A0A0"
                                FontSize="16"
                                FontWeight="SemiLight"/>
                        </StackPanel>
                    </Grid>
                </ContentControl>
            </DataTemplate>

    And this is my listBox:
    <Primitives:RadDataBoundListBox x:Name="listBox"
                       ItemsSource="{Binding Source}"
                       ItemTap="listBox_ItemTap"
                       Tapped="listBox_Tapped"
                       ItemTemplate="{StaticResource ListBoxItemTemplate}"
                       ItemReorderStateChanged="listBox_ItemReorderStateChanged"/>

    My source is an ObservableCollection. How can I pick an element from that collection and enable the itemReorderMode for that element?
    I need the IsItemReorderEnabled parameter to be set to False, and I just want to enable that mode for a given item programmaticaly.
    That method only accepts a RadDataBoundListBoxItem object, and I don't know how to get that from the actual element I pick from my ObservableCollection.

    Thanks in advance :)
    Sergio
  2. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 30 Jan 2015 Link to this post

    Hi Sergio,

    You can use the GetContainerForItem method of RadDataBoundListBox. It accepts an object parameter -- an element from your observable collection, and returns a RadDataBoundListBoxItem.

    Best regards,
    Ves
    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.

     
  3. Sergio
    Sergio avatar
    18 posts
    Member since:
    May 2014

    Posted 30 Jan 2015 in reply to Ves Link to this post

    Hello, thank you for your answer!
    I didn't see those two methods as they returned a RadVirtualizationDataControlItem, I just realized that a RadDataBoundListBox inherits that class, by bad :D
    Thank you again for your help!

    Sergio
Back to Top