I have a windows form that contains two usercontrols. One usercontrol contains two list views. The other usercontrol has a grid.
Within the first usercontrol the two list views drag and drop their contents between each other.
The grid usercontrol is setup to dragdrop onto the listview usercontrol.
The problem is that the drag drop event within the listview usercontrol always takes precedence over the dragdrop between the two usercontrols.
So if I drag from the grid usercontrol over the listview usercontrol it will execute the internal dragdrop event of the listview control.
In other words it fires this event
lv_groupActivites_DragDrop
instead of
reservationScheduleBooking1_DragDrop
Is there anyway of specifying which drag drop event should be fired?
You are dragging from the grid in one user control and trying to drop onto a specific listview on the other user control or anywhere on the other user control?
If you want to drop anywhere on the other user control, I think you will need to setup the apprporate event handler on that user control to respond. If you want to drop on to a specific listview that also accepts drag events from the other listview you will need to do extra work in your event handler on that listview to figure out where the drag initiated from.
Related
I have a custom control that is made up of two main controls, a FlowLayoutPanel on the left side, and a TabControl on the right side. The FLP is just used to store custom "buttons" that change the selected index of the tab control. I have it working at design time so that I can select the buttons and move through the pages.
I'm trying to make it so that I can drag controls to those pages, but the controls are just being added to the custom control.
Any ideas on how to accomplish this task?
I'm trying to build a WPF control inheriting from Selector and I want to change the state of the control when one of its items are selected in the design surface. Despite hooking on a debugger, I can't seem to capture any useful events from the control. I've managed to capture it being initialised and the wrappers for its child elements being initialised around the items of the selection, but I can't see any change of state, or event being triggered when the control is selected.
Importantly, I want to detect when the item is selected either by the user selecting the control in the design view or in the markup.
I'm trying to achieve a behaviour like that of the TabControl, where selecting a tab brings it to the front and exposes any content associated with the tab. I can't fathom how it works at design-time though.
What do I need to do to detect that a control is selected?
I'm writing an application that is creating most of the WPF interface with C#. When the user double-clicks a node in a tree view, an instance is created of a class I designed.
That class handles everything else - creating a ListView control and a GridView, setting the ListView view to the GridView, and finally creating a new TabItem, populating it with the ListView, and adding the TabItem to a pre-existing TabControl.
I'm running into problems adding a GridViewColumn.Click event handler to my ListView, because I want the function for the click event to be in my main window class, not the separate class that creates the ListView and GridView.
I've figured out how to use ref to reference the TabControl in my WPF window from my separate class, but what about functions? How can I add a click event handler in my class that references a function in the main window class?
I would use a command instead of a event handler. Then you can bind the command to whichever class you want to handle it
check Bind event to ViewModel
I am creating an application in which i have a user control that can be added by user dynamically any number of times. Form also contains some other controls.
Suppose he has added the control 10 times.
Requirement:
1) When the control is selected, it should be highlighted and when the
other control is selected then the previous control looses the glow.
2) User can select multiple controls at the same time. Now all the
selected controls should be highlighted and the selection has to be
made with ctrl key.
There is also a possibility of moving the controls on the form.
What I have achieved:
1) I am able to add multiple controls dynamically.
2) I can change the location of one control dynamically.
3) I am able to highlight the control when it is clicked, but not able
to un-glow it when user has clicked elsewhere. Need to know which event of User control can be used for that. -- Got the solution for this. On mouse click i made the focus on the control and then handle GotFocus and Lost Focus events to golw and un-glow the control.
Problem Left:
No success in selecting multiple controls and dragging them
simultaneously. If i would be able to select multiple controls then
dragging would not be very difficult.
If you are talking about buttons, unfortunately you cant select multiple at a time..
I have FlowLayoutPanel and UserControl's on it with drag & drop reordering. This sort of works. But the problem is that child controls prevent dragging of the actual parent UserControl.
So my question is how to enable dragging of a UserControl that contains child controls?
If I understand you right I had the same problem as you and I solved it by propagating events of the child element to it's parent.
If you have a draggable UserControl containing a label. You have to call the events of the UserControl when the events of the label occurs. E.g. in the Label's OnMouseDown() call the UserControl's OnMouseDown() and just pass the Event-Args. I didn't find a better way than handling each event that is required for drag and drop separately.