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

How to call the ActivateItemReorderForItem method

2 Answers 38 Views
DataBoundListBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sergio
Top achievements
Rank 1
Sergio asked on 27 Jan 2015, 10:16 PM
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 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 30 Jan 2015, 08:47 AM
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.

 
0
Sergio
Top achievements
Rank 1
answered on 30 Jan 2015, 10:48 AM
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
Tags
DataBoundListBox
Asked by
Sergio
Top achievements
Rank 1
Answers by
Ves
Telerik team
Sergio
Top achievements
Rank 1
Share this question
or