Extended Selection in WPF Listbox - wpf

we need to customise the Extended Selection in WPF ListBox.
What I need to do is be able to Drag and Select Multiple items(Similar to selecting in excel)
Extended selection in Listbox works fine but for that I have to hold the Shiftkey and drag.
Is there a way I can do the multiple selection just by dragging and not holding the shift key down?
Thanks for looking.
Regards
Saurabh Dighade

This looked promising. I haven't tested it though.
http://www.codeproject.com/KB/WPF/MultiSelectListView2.aspx
Also, a similar SO post: Drag-select with ListBox

Related

How to expand treeviewitem while performing drag and drop operation

When performing dragging over TreeView I want items to expand automatically when mouse cursor is over them for some time (eg. 2 seconds). What would be the approach to solve this problem?
Ideally I'd like to have a custom attached behavior implementation of this problem, something like for scrolling while dragging: http://weblogs.asp.net/akjoshi/archive/2012/05/28/Attached-behavior-for-auto-scrolling-containers-while-doing-drag-amp-drop.aspx
In addition, I'd like to handle any other expandable (eg. Expander) or content-selectable (eg. TabControl) elements in a same manner, but I am not sure if all this can be handled generically (eg. with one attached behavior) or do I need to handle all of them separately?
See my blog article entitled Xaml: Adding Visibility Behaviors Using Blend to A DataGrid for WPF or Silverlight where it demonstrated a mouse over trigger. From that you can apply the behaviors you need using Blend to do the dirty work of adding the triggers.

XamDataGrid XamTabControl WPF MVVM Peculiar Behavior

I'm facing a problem in implementing the following scenario:
When the user selects a record in a XamDataGrid, the control flows into another tab showing the details of the selected record.
The way I have done this is:
At the selection change of the XamDataGrid, I'm sending index of the tab to be activated using MVVM Light Messenger.
Setting the property bound to the Seledted Index of the Tab Control to that number.
Everything works smooth till here. Afetr that if I go back to the tab containing the grid, somehow the control comes back to tab which was activated.
As if, some intrinsic selection of cells in happening in the grid. Does Hover also affects the selection of the xamdatagrid?
I'm new to Infragistics and kind of confused. If some one can help.
All code are in View Model files and no code in the code behind of xaml file.
Cheers,
Anshuman
I played around a lot.
But the only way to get this wqorking was to disable all hover animations and effects.
Now it works as expected!

Drag Drop with multiselect

I've implemented drag-and-drop from a listbox to a treeview with the help of this question. The only thing I haven't figured out yet is how to drag more than one item from the listbox. I've enabled multiselect on the listbox, but when I have multiple items selected and start the drag, it deselects everything except for the item directly under the mouse pointer. Has anyone gotten drag-and-drop to work with multiselect, and if so, how?
You have to keep the ctrl or shift key pressed when you begin the drop, if you let go the listbox goes back to 'begin select' mode again.
I see this as a bug in the framework as the multi-select behaviour is different to the one in Windows Explorer and is not intuitive at all. See my suggestion here.

How do I drag and drop between two datagrids in wpf?

For example, dragging a row from a datagrid table to another datagrid table?
However the other datagrid table just present the row, it manipulates the data gathered and present it in its own way.
I am using wpf toolkit. Can show me a sample example on this?
Here is a good place to start. Although the tutorial is shown for ListBox, it can also be adapted for DataGrid (although I have not tried it for myself).

WPF DataGrid ContextMenu(s)

How can I define different ContextMenus for each column in the DataGrid (Microsoft's grid)? I found out that the grid provides a ContextMenu attribute, but i want different context menu items for the columns, not the same ContextMenu for the whole grid.
Edit: Thanks for your answer! I tried to listen to the ContextMenuOpeningEvent as you suggested which was a first success: the ContextMenu can be modified in the EventHandler. But it raises another (hopefully small) problem - I now have to identify the column the mouse cursor was over when the ContextMenuOpeningEvent was triggered. I'm going to research how to do (or work around) that later.
I haven't played with it at all, so this might be wrong, but you may be able to override the ContextMenuOpening event and create the appropriate menu on the fly.
add menu item to default context menu might give you a starting point.
Good luck.

Resources