Code behind does not get called on dynamically created user controls - xaml

I am writing a WPF VMMV application.
- I am dynamically loading XAML into the window that contains user control.
- The user control has a textbox besides other simple controls
- The textbox has MouseDoubleClick and KeyDown events
Now, when I load a XAML which has my User Control, the control can be seen (as in the XAML designer), but the events won't work.
I have tried to make the user control with the MVVM pattern instead with code behind. That also does not work. Any experience with this or suggestions?

Related

VB.NET Win. Form - Showing a custom control outside of the container control

I have a created a custom user control which consists of 2 controls:-
Textbox
Listbox
The function of this control is to act as a dropdown list. Below is the image of the control:-
Problem
Now the problem i am facing is that if i insert this user control into a container control like a panel then the list gets hidden inside that container control.
and if i just create the user control outside the container control then it would interfere with the Tab Order (focus order) of the form.
Is there any work around where the user control exists in the container control and still shows the complete list without being hidden in the panel?
Edit i wrongly added c# instead of VB.NET
It can be achieved by having the list as ToolStripDropDown. Similar customization have been done in the following discussion,
Show control inside user control outside the boundaries of its parent
Hope this suits you.

Menustrip Style Custom Designer in VB .NET

I am trying to create a user control and custom designer. The perfect example of what I am trying to achieve in design time is how the menuStrip allows you to enter the text of the item being added.
This tells me it is possible, but I do not know if they are just drawing a box/cursor and just handling the key events individually or if they are using a textBox control in the designer somehow.
Is there a way to use controls in the designer during design time?

AutomationPeer - how to show data of elements not on the control?

I want to write an AutomationPeer for my custom control in WPF.
Now, I want to show textBlocks \ TextBoxex that are not actually visible on my control.
I know how to override the method GetChildrenCore().
My problem is that when i run the playback (coded ui record) - it's trying to find a control not vissible on the window. Have you got any ideas?
You can set the SearchConfiguration VisibleOnly on the Coded UI control. Also, the UITestControl.FindMatchingControls method can let you know if the search properties are too ambiguous. Coded UI stops looking for a control after the first instance of a matching control is found.
inspect.exe can shed light on a form and how Coded UI may be seeing the control.
Try opening the Designer.cs and see the hierarchy and what Coded UI is trying to find.

I want to make a control builder program when I add my custom control to the winform - VB.NET, VS2008

I am currently building custom user controls and would like to have a program (that I write) that sets the properties for the control when it is dragged onto the form.
I've seen this working with some controls I've been using - an external program opens (or is available by right clicking on the control).
How is this accomplished?
Edit: An example of an application I use that does this is Farpoint Spread Designer; You can right click on the component and launch the designer application.

Clone Winform control

I have a groupox in a VB.NET winform app. The groupbox contains a few Labels, Textboxes and Checkboxes. This was created by simply dragging the controls out of VS toolbox.
What I need to do is take the 1 Groupbox and at runtime create multiple Groupboxes to display based on user selection. Instead of dynamically creating the Groupboxes and other controls nested inside, is there a way to clone or copy the original one.
Then I'd just change the properties. Label text, Textbox text, etc. And the location of the Groupbox in the layout.
What you could do is create a user control based upon your groupbox which would allow its reuse. You could then create the instances you require at runtime and add them to the form.
Maybe suggest that you look into creating user controls for winforms.
Could this be a help to you?
How to Clone/Serialize/Copy & Paste a Windows Forms Control