Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
320
Drag&Drop CellValue on ContextMenu
posted

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.

Parents Reply
  • 2490
    Offline posted in reply to Pablo

    Hello Pablo,

    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

    XamDataGrid_DragDrop.zip
Children