Hi Guys,
I want to achieve the following in a xamDataGrid.
When a I start dragging a cell value, I want to display a contextmenu, and drop the cell value on one of the options in the menu. Then, according on the option selected when drop the value, I'd like to fire the event associated to that option. I was wondering if you have something like this already done?. Could you provide an example?
Thanks in advance.
Hello,
I have prepared a custom application and used a variant right mouse click.
I hooked two different handlers to each option, you can easily change that and use one handler and take for example the option's header and the cell which is clicked. Please, test it with right mouse click on different cells and choosing a different options. If this does not reproduce your scenario, please let me know.
Hi Nick,
Thanks for the example you've sent.
Actually I've been following this approach and it Works, but I really need to do it with Drag&Drog since I have behavior in place when users left click on a cell. Is it posible to solve this this way?.
Thanks in advance!
Best,
Pablo
Hello Pablo,
Can you provide me with some more information about the functionality you require and want to achieve. The context menu can be opened with drag, but it closes when the drag continues. You have implemented a behavior on left mouse button and thus you do not need one on the right button?
Is it an option the cell's content to be dragged to a different control? For example a text box which can accept it (please see an example of this as an attached application)? If the drag event starts and opens a context menu can this menu be used to be clicked rather than drop an item in the options?
If you are able to provide some more information on what have to be accomplished it will help me to further investigate this for you.
You can achieve this by getting the mouse position in the application. After that you can set the StackPanel’s position when the drag starts. To show an example I have modified the previous application. Please see it as an attached file.
Great stuff!. This is exactlu what I need!
One last question. Is there any way to open the StackPanel in the same location where the mouse is?.
Thank you for the detailed description.
I have looked into your requirements and I will suggest using the Infragistics Drag and Drop Framework. It will facilitate the moving of elements in your application. To illustrate its functionality I have prepared a custom application. I have used the CellValuePresenter's style (which you can find on your computer in C:\Program Files (x86)\Infragistics\2016.1\WPF\DefaultStyles\DataPresenter\DataPresenterGeneric_Express.xaml) and I have updated it with the following code:
<igWindows:CardPanel MouseDown="CardPanel_MouseDown" >
<ig:DragDropManager.DragSource>
<ig:DragSource IsDraggable="True"
Drop="DragSource_Drop" DragOver="DragSource_DragOver"
DragStart="DragSource_DragStart"/>
</ig:DragDropManager.DragSource>
Creating a Drag Source in this way. I have also included a StackPanel (for an example, you can easily use another element), which I have used as a Drop Target. Please notice that the TextBlocks which are set to be options can also be set to Drop Target and thus locating the exact place where the element has been dropped.
If you have further questions concerning this matter, please let me know
Thank you very much for your feeback!.
This is a trading client application. The grid is populated with data related to instruments and prices. So, the idea would be to allow the users to submit, update or remove orders by dragging any selected Price and dropping it into a menú option (doesn't has to be a context menú), or whatever control that gives me the posibility to fire the expected behavior. What´s expected is that the menú opens when I start dragging, and closes when drop the Price.
I've been looking at the example you've sent, and basically the behavior I want is that, but instead of a single textbox, I would need to customize it to present a list of options.
Please let me know if this provides some context.
Thanks in advance.!