locked
ListView programmatically veto a selection change triggered from the UI

    Question

  • Hi,

    I would like to create a page with a master-detail-construct, having a ListView of objects and when the user selects an object, a series of TextBoxes appear next to it, so the object can be modified.
    When the user chooses a different object in the list, I would like to show a MessageDialog asking, if the changes should be saved, discarded, or if the user wants to continue working on the previously selected item and not change the selection.

    So far so good. I can get it working, the only thing that is not quite right is, that so far I cannot prevent that the new item is already selected in the UI.  From a user experience point of view, that's not ok ... when the dialog is shown, the old item should be still selected not the new one.

    Is there any way, that I can intercept the selection change before it happens on the UI?

    Regards,

    Rico

    Monday, November 3, 2014 1:29 PM

Answers

  • Hi,

    I think figured out a way to do it.

    It seems that by setting an ItemClick handler, I can take over control of what happens, when an item ist clicked. The two-way binding, I defined in the XAML, is "interrupted", but I can keep it working as before, if I set the SelectedItem in my handler.
    It's actually pretty cool and clean ... I can show the message and change the selection if the user agrees to it, if not, the selection stays where it is.

    Regards,

    Rico

    • Marked as answer by schlumpfling42 Wednesday, November 5, 2014 11:27 AM
    Wednesday, November 5, 2014 11:27 AM

All replies

  • Hi,

    Are you using Javascript to Show confirmation box during next object selection?


    Did you find this Helpful? Please Mark it So! Thank you. Sachin Kumar

    Monday, November 3, 2014 1:34 PM
  • Hi,

    No, I'm using C# to implement the project.

    Regards,

    Rico

    Monday, November 3, 2014 1:48 PM
  • Hi,

    I think figured out a way to do it.

    It seems that by setting an ItemClick handler, I can take over control of what happens, when an item ist clicked. The two-way binding, I defined in the XAML, is "interrupted", but I can keep it working as before, if I set the SelectedItem in my handler.
    It's actually pretty cool and clean ... I can show the message and change the selection if the user agrees to it, if not, the selection stays where it is.

    Regards,

    Rico

    • Marked as answer by schlumpfling42 Wednesday, November 5, 2014 11:27 AM
    Wednesday, November 5, 2014 11:27 AM