Reordering book items error

10 posts, 0 answers
  1. Nebojsa Danilovic
    Nebojsa Danilovic avatar
    18 posts
    Member since:
    Feb 2010

    Posted 14 Dec 2013 Link to this post

    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
  2. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 18 Dec 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Nebojsa Danilovic
    Nebojsa Danilovic avatar
    18 posts
    Member since:
    Feb 2010

    Posted 18 Dec 2013 Link to this post

    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
  5. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 23 Dec 2013 Link to this post

    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 >>
  6. Nebojsa Danilovic
    Nebojsa Danilovic avatar
    18 posts
    Member since:
    Feb 2010

    Posted 23 Dec 2013 Link to this post

    Hi Martin,
    thanks very much. This is exactly what I need. Excellent !
    Best regards
    Nebojsa 
  7. Nebojsa Danilovic
    Nebojsa Danilovic avatar
    18 posts
    Member since:
    Feb 2010

    Posted 24 Dec 2013 Link to this post

    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
  8. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 26 Dec 2013 Link to this post

    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 >>
  9. Nebojsa Danilovic
    Nebojsa Danilovic avatar
    18 posts
    Member since:
    Feb 2010

    Posted 19 Jan 2014 Link to this post

    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
  10. Nebojsa Danilovic
    Nebojsa Danilovic avatar
    18 posts
    Member since:
    Feb 2010

    Posted 19 Jan 2014 Link to this post

    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
  11. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 22 Jan 2014 Link to this post

    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready