Can I override DataGrid's mouse events?

G

Guest

Is it at all possible to override the default behavior of a DataGrid when the
mouse is clicked on a row? I am having a problem where I am trying to select
multiple rows in a DataGrid by left-clicking them, but each time I click
another row to add it to the selection the previously added row loses it's
highlighting, so it appears as though only one row is selected at any one
time.
 
G

Guest

Update:

I made my own DataGrid extension and override the onMouseUp and onMouseDown
events. I then put in my own code which is supposed to make it so the user
can select multiple rows by clicking them one by one while holding the CTRL
key (and they all stay highlighted until they de-select them-- much like how
Windows Explorer works)

But now I lost all the other behavior of DataGrid which I want (click column
header to sort, resize columns). Using a .NET Resource tool a guy two
threads up from me suggested (so I can see DataGrid's source) helps alot to
see what DataGrid was doing but I can't simply copy the behavior I want from
these methods because certain properties and methods it uses has private
access.

The only thing that preventing my selection goal from working was one line
of code in the onMouseDown method of DataGrid which resets the selection (so
any previous row loses it's selection once I CTRL + left-click another row) I
wish I can just copy the whole method but comment out that one line but
again, because of access level restrictions I have no such luck.

So is my only choice to reinvent the wheel in regards to the other DataGrid
behavior I need (column resize, sorting) if I want my custom selection
behavior to work?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top