2

I basically want to create something like this:

So, a user can add/remove items from the list and edit them in the red panel below the list. When the item is selected, the changes can be made in the panel.

Then, the changes can be either saved or canceled with one of the buttons below. User cannot select another item in the list without explicitly cancelling the changes.

How to do this? I only see the option of making the red panel a separate control and changing its DataContext manually on ListView.SelectedItem changes. The red panel's DataContext is a special wrapper on a ListView's item which has 'save' and 'cancel' options. ListView is set to IsEnabled = False so that its SelectedItem doesn't change when editing is in progress.

How would you do this?

Mikhail Orlov
  • 2,789
  • 2
  • 28
  • 38
  • The first thing comes to my mind is using Grid and allowing directly editing inside it via some edit link in each row... something like that. Any specific need to use ListView? – Adil Jul 18 '12 at 07:20

3 Answers3

2

the most easy apporach is to use a dialog for edit a selecteditem. thats what i do in my project. i use this dialogservice and handle the result.

if you want to handle all in one view you could set a property SelectionEnabled=false when the SelecteItem is set. and then SelectionEnabled=true when the save or cancel command is invoked.

the datacontext for your edit panel is simply your SelectedItem.

Community
  • 1
  • 1
blindmeis
  • 22,175
  • 7
  • 55
  • 74
2

The question is quite close from, for example, this one : How do I stop binding properties from updating?

Anyway the WPF Object that will handle this is the BindingGroup :
http://msdn.microsoft.com/en-us/library/system.windows.data.bindinggroup.aspx

Community
  • 1
  • 1
GameAlchemist
  • 18,995
  • 7
  • 36
  • 59
0

You can try to use bindings with UpdateSourceTrigger=Explicit. The blog post Edit With Explicit UpdateSourceTrigger will give you more information about how this can be implemented.

Tony
  • 9,672
  • 3
  • 47
  • 75