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

ItemReorder Missing Events

5 Answers 68 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.
Jonas
Top achievements
Rank 1
Jonas asked on 28 Jan 2013, 02:42 PM
Hello

I'm looking into the ItemReorder funktionality within the DataBoundListBox

I need a way to control if the item can be reordered or not. Is there an event or command when an item is about to be reordered or any other way to disable the reordering for a specific item in the ListBox?

I also need a way to hook up an event when the reordering is done e.g. when the reorder buttons is closed. 

Regards
>> Jonas

5 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 30 Jan 2013, 11:23 AM
Hi Jonas,

Thank you for contacting us. Currently, we don't have a straightforward way to achieve you scenario. But with few additional lines it can be achieved to a certain degree.

Let's assume the DataBoundListBox control is bound to a list of integers:

List<int> numbers = new List<int>(Enumerable.Range(0, 10));
this.dataBountListBox1.ItemsSource = numbers;

For the sake of the example, let's say we want to be able to reorder only odd numbers. To do that, we'll have to listen for the Hold event of the DataBoundListBox control:

<telerikPrimitives:RadDataBoundListBox x:Name="dataBountListBox1" Hold="DataBountListBox_Hold" >
    <telerikPrimitives:RadDataBoundListBox.ItemTemplate>
        <DataTemplate>
            <Grid Margin="5" Background="LightGray">
                <TextBlock VerticalAlignment="Center" Text="{Binding}" FontSize="32" Foreground="Black"
                        Margin="0 5" />
            </Grid>
        </DataTemplate>
    </telerikPrimitives:RadDataBoundListBox.ItemTemplate>
</telerikPrimitives:RadDataBoundListBox>

In the event handler, simple get a reference to the DataBoundListBoxItem we've been holding and based on its DataContext, determine whether reordering should be allowed or not:

private void DataBountListBox_Hold(object sender, System.Windows.Input.GestureEventArgs e)
{
    // get an instance of the DataBoundListBoxItem
    RadDataBoundListBoxItem item = ElementTreeHelper.FindVisualAncestor<RadDataBoundListBoxItem>(e.OriginalSource as DependencyObject);
    // for testing purposes allow reordering only of odd numbers
    int number = (int)item.DataContext;
    if (number % 2 != 0)
    {
        this.dataBountListBox1.ActivateItemReorderForItem(item);
    }
}

However, we still don't have a mechanism which notifies you once reorder has been completed.
Give this approach a try and let me know if it works for you.
I'd be glad to assist you further.
Greetings,
Kiril Stanoev
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Matti
Top achievements
Rank 1
answered on 25 Oct 2013, 11:27 AM

I have a further/related question for this: How can I know when user has finished reordering (when the reorder buttons have disappeared). Need to hook up to this kind of event to be able to save the updated order into cloud service. Or is there an another/better way to accomplish the same results?


0
Deyan
Telerik team
answered on 28 Oct 2013, 11:14 AM
Hi Matti,

Thanks for writing.

There is not currently a straightforward way to know this. We can expose an event that informs you about these state changes in Q3 2013 SP1 timeframe (in a month or so). Let us know if this is alright with you?

Regards,
Deyan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINDOWS PHONE 7.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Matti
Top achievements
Rank 1
answered on 28 Oct 2013, 11:35 AM

Thanks Deyan,


This will do fine. Meanwhile I can use a timer-based approach, which is dirty and unsecure, but works in most cases. If user exits the app before timer has launched the saving of the data, changes are lost. Also, polling the isDirty with a timer possibly unnecessarily consumes battery of the device. Since there is currently no way of knowing when the user has finished editing, the save timer can launch the saving even if user is still modifying the list.



As soons as the new event is exposed, I will start using it. It will provide a much simpler and cleaner approach to saving the updated data. :-)



0
Deyan
Telerik team
answered on 30 Oct 2013, 03:06 PM
Hello Matti,

Thanks for writing back.

We will be releasing an Internal Build containing the latest bits, the aforementioned event included. You will be able to download the IB from our website.

Stay tuned.

We will consider this thread closed for now. Let us know if you have further questions.

Regards,
Deyan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINDOWS PHONE 7.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
DataBoundListBox
Asked by
Jonas
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Matti
Top achievements
Rank 1
Deyan
Telerik team
Share this question
or