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

Reordering book items error

9 Answers 49 Views
Book
This is a migrated thread and some comments may be shown as answers.
Nebojsa
Top achievements
Rank 1
Nebojsa asked on 14 Dec 2013, 04:15 PM
Hi,
I have radbook which itemsource is ObservableCollection of objects of type BookPage (my object). I also have listbox with itemsource also connected with same ObservableCollection. What I try to accomplish is to use ListBox as Table of Content and to jump to particular page using it, and book pages should follow order of items in listBox. Everything works fine when I am adding or removing items in ListBox, but when I try to reorder items in listbox, sometimes one or two pages in book are lost, or to be absolutely precise, items in listbox are on correct places, pages are still in book, but I can not see them. (strange effect is showing: when I am flipping through book, that "lost" pages are "showing from nothing" and disapear to nothing  - pages are blank, I can not see any content on them. Can you suggest some solution to this problem, I suspect that something must be done with Collection, but can not figure  out what and how. Listbox always looks fine, 
Thanks in advance
Nebojsa Danilovic

9 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 18 Dec 2013, 04:49 PM
Hello Nebojsa,

We reproduced an issue where the RadBook ItemsSource items are reordered using the ICollection Remove() and Insert() methods. We logged this bug in the feedback portal under the name Reordering the ItemsSource makes the component unresponsive and hides some of the pages.

Can you confirm if this is the approach (removing and then inserting items to reorder them) you're using in your application. If not, can you please send us a sample project demonstrating your implementation so that we can investigate that case as well.

Also, please note that if you reorder the ItemsSource collection through the ObservableCollection Move() method, the issue is not reproducible. This approach is demonstrated in the attached project.

Regards,
Martin Ivanov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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
Nebojsa
Top achievements
Rank 1
answered on 18 Dec 2013, 08:37 PM
Hi Martin,
Thank You for fast response. Yes, I am using same method for reordering, because draganddrop reordering behavior in RadListBox use same approach ( remove() and insert()). Ok, for now, I have to use move() method of ObsevableCollection. I have one more question about this: if I want to have some kind of visual indicator on the selected page ( because I always look at two open pages ), just to know which page is currently selected, what would be the best approach? How to track mouse click on book page and update list box, and vice versa?
and, as P.S
What about deleting from Observablecollection. Will that cause same error?
Best Regards
Nebojsa Danilovic
0
Martin Ivanov
Telerik team
answered on 23 Dec 2013, 04:56 PM
Hello Nebojsa,

Unfortunately the RadBook doesn't have a build-in Click event, that's why you have to register new class event handler if you want to click on the pages. You can create indication for the current opened page with custom style.

I create a project to demonstrate how you can achieve this result.

Regards,
Martin Ivanov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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
Nebojsa
Top achievements
Rank 1
answered on 24 Dec 2013, 01:37 AM
Hi Martin,
thanks very much. This is exactly what I need. Excellent !
Best regards
Nebojsa 
0
Nebojsa
Top achievements
Rank 1
answered on 24 Dec 2013, 06:56 PM
Hi again,
Martin, can you explain me how IsSelected property is reset to false when page is not selected, i can not figure out, my all pages are always selected. And, is there any workaround for deleting items from ObservableCollection, because I still have errors (strange book behavior) when remove items.
Regards
Nebojsa Danilovic
0
Pavel R. Pavlov
Telerik team
answered on 26 Dec 2013, 03:51 PM
Hello Nebojsa,

Please note that the IsSelected property of the RadListBoxItem is bound, in TwoWay mode, to the IsSelected property exposed by your ViewModel. Since, this fact the RadListBox control sets the property to false. If you follow the exact same approach in your custom scenario, the only way to have more than one item selected is to configure the RadListBox to have multiple selection.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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
Nebojsa
Top achievements
Rank 1
answered on 19 Jan 2014, 11:42 AM
Hello Martin,
how to refresh book after reordering pages(I am using listbox (itemssource=ObservableCollection(Page)) for reordering). Is there any method just for refreshing book?
best regards
Nebojsa Danilovic
0
Nebojsa
Top achievements
Rank 1
answered on 19 Jan 2014, 11:54 AM
And , sorry,
one more question:
mousedown event from your example working very good, but, unfortunately, if I click on richtextbox or button, it is not fired at all. I tried e.handled=true on mousedown event on richtextbox, but it is not working. Any idea?
Beset regards
Nebojsa Danilovic
0
Martin Ivanov
Telerik team
answered on 22 Jan 2014, 09:33 AM
Hello Nebojsa,

In order to fire the MouseLeftButtonDown event handler for controls inside a RadBookItem, you will need to set the last argument of the RegisterClassHandler() to true. This will invoke the handler, even if the event is marked as handled in its event data. Here is an example:
EventManager.RegisterClassHandler(typeof(RadBookItem), RadBookItem.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnMouseDown), true);

Also, can you please tell me what you mean with "refresh book". I suppose that when you reorder the items, you want the currently opened pages to be updated. In this case and if you use the ListBoxDragDropBehavior or the DragDropManager, the pages should refresh automatically by default.

However, the RadBook could be refreshed if you use the RadBook.Items.Refresh() method, but this will open the first two of pages. Another approach you can use is to reset the value of the RightPageIndex property.

I prepared a sample reordering implementation, which I attached. Please let me know if I am missing something.

Regards,
Martin Ivanov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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
Book
Asked by
Nebojsa
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Nebojsa
Top achievements
Rank 1
Pavel R. Pavlov
Telerik team
Share this question
or