Silverlight DataGrid selection and drag-drop - silverlight-4.0

I am currently implementing drag and drop using the DataGrid provided in the Silverlight SDK and I want the user to be, easily, able to drag multiple items to another list.
The grid's selection gets updated on the MouseDown event so the only way the user have to drag multiple items is to press Shift while begining the drag operation. This is not really obvious and, for me, the natural way whould have been to just click the selected block of rows and drag them. To do so, the selection needs to be updated on the MouseUp event.
I've tried to derive from the DataGrid to inject my custom DataGridRows but the DataGrid doesn't expose a way to replace the type of rows it creates.
Anyone have a solution or ideas for this?
Thank you,
Jacques.

Yes, it's unfortunate that the selection is updated on mousedown. You will need to perform some work in the mousedown event to work around this. This codeproject article should help:
http://www.codeproject.com/Tips/338594/Drag-drop-multiple-selected-rows-of-datagridview-w

Related

Trouble traversing Visual Tree in C++/WinRT

I'm implementing an app w/ Excel-style functionality where I have a ListBox of baskets, each containing a ListBox of Items, each containing a StackPanel-nested Button inside it.
XAML, What the layout looks like
Goal: I want to click on the button, such that the item entry (StackPanel) is highlighted via SelectedIndex(). I try to accomplish this in the GotFocus="ItemGotFocus" event handler, by traversing the visual tree to find the parent ListBox, so I can call SelectedIndex() on it.
However, I am getting errors whenever I call VisualTreeHelper::GetParent() or other functions from the namespapce in general:
Do I need to define a template definition somewhere, so it can figure out the type I want it to return, or is there a better way to go about this?
Thank you, it worked!
Turns out I had included <winrt/Microsoft.UI.Xaml.Media.h> in "pch.h", when what I really needed was <winrt/Windows.UI.Xaml.Media.h>.

Context menu to delete items from a ComboBox

Currently, I've designed my own combobox from a ListBox/Button/TextBox to accomplish this, but I'm finding this to be way to much work to try and get a hacked together ComboBox to look like an actual ComboBox control.
This does however give me the desired effect however. Sort of ...
But my question is, is there not a simpler way to do this? Is there a way to simply right click on an item in a ComboBox, and get a context menu that says "Delete" for that specific entry?
Here is an example of the desired effect with my hacked together ComboBox:
I've tried simply linking a ContextMenu to a ComboBox, but that only allows for right click on the actual ComboBox itself, not the drop down, which renders this useless to me.
Any help or advice would be greatly appreciated.

Custom DataGridView Cells

I need to create a custom control based on a datagrid. My need is to show the events of the day (I know there are other third-party controls).
I should redesign the cells in the datagridview but I do not know where to start, obviously do not want the code I understand that it is not a simple thing, but I would like to see one of your left indication on what to focus on.
Below is an image of what I would get

Is there an event which fires before a user enters a row into the datagridview in .net 3.5

I am trying to create a wrapper to replace the sheridan datagrid actvex control with a datagridview.
The sheridan datagrid control supports an event which fires just before the user is going to add a row to the grid called BeforeInsert.
Does anyone know of an equivalent event in the datagridview control or or some other code I could write which produces the same effect?
I'm having a look at all the events here, I don't see one for Adding or Inserting a row, just Added. Although there's one for Deleting and Deleted strangely enough. I won't pretend to know why. To your question, how exactly will users be adding rows? You could try playing around with the "AllowUserToAddRowsChanged" event and change that property programatically when the user wants to add a row.

limit selections in a listbox in vb.net

I am creating a web control in vb.net that contains a list box. I know that I am able to choose a selection mode of Single or Multiple, but I am interested in limiting a Multiple selection to a predetermined size. For example preventing a user from selecting more than 3 items.
I have tried adding a Validator to the list box, which might be a way forward, but was wondering if there was a way of changing the selection mode to something a bit different than just the two specified ones.
Any ideas or suggestions would be greatly appreciated
Edit: Unfortunately due to project limitations I am unable to use Javascript on this problem. very annoying I know!
You could try handling one of the SelectedIndexChange events. With multiple selection, each time this event fires you can check how many items have already been selected. If it is more than you want, have the handler deselect the one that was just selected. You could also put up a little red label under the listbox saying "Sorry, no more than [n] selections allowed."
EDIT:
Just noticed you said WEB. Same theory applies, but it would have to be done using Javascript.
On the SelectedIndexChanged event, write a short piece of code that will check the number of selected items and if it is greater than your desired amount, unselect the new selection (or unselect the oldest one, or however you wish this to operate).