Silverlight StackPanel (or UserControl) focus issue - silverlight

I am deriving a custom control from StackPanel (or just using the usual UserControl class). This control should be focusable within the application by either tabbing or clicking the control. When focus occurs, based on other criterion the control will expand and show certain elements. The control will also choose a default child control to focus on.
The issue I have is that I can find no way to focus on a UserControl. The Got/LostFocus events don't fire when I click on the control.
I am aware of the Focusable property, but it doesn't seem to be available on any of the client dlls for Silverlight (using v4 of SDK)
What I would really like is some advice on how best achieve the functionality of a panel I can tab to, as the UI design I have in mind hangs on this.

I guess the control you are looking for, is an Accordion or Expander control.
Here, you will find steps to use the Accordion control. Hope that helps.

Related

Moving (dragging) HwndHost using mouse

Here's what I am trying to accomplish - To create an MDI application in WPF, which can host child web applications. I am using WPF webbrowser control to render web applications. WPF inherently doesn't seem to support MDI applications, so after a bit of searching, I found this project, which uses UI controls to simulate windows and manages them inside a WPF canvas. This approach seems to work reasonably well until I start adding webbrowser control object as an MDI child.
When I add webbrowser control as an MDI child, it always appears on top of other WPF elements including other MDI child controls (as shown below). From what I understand, webbrowser control always appears on top of any other WPF object except for window (and popup). Assuming that's true, I think I need to use actual WPF window to avoid overlapping issue.
The only solution i can think of right now is to wrap WPF window inside an HwndHost object and then add that as an MDI child. However it appears that a child window cannot have title bar. That means that i need to have a window that has a dummy title bar area (just like actual window title bar) and actual content area (which will show webbrowser control) as shown below (Red border is HwndHost object).
This approach seems to solve the overlapping issue. The next thing i need to try is to let users click on the dummy title bar and drag the MDI window inside the canvas element.
Questions -
Is my understanding about WPF webbrowser control overlapping behavior right? If not, what am i missing?
Is the second approach a step in right direction for accomplishing what i want? If yes, how do i implement the drag behavior for HwndHost?
Is there any other alternate solution i can try?
Note:
Although many consider MDI not an elegant solution, I do not have a choice. (We tried alternate solutions like tabbed windows/dockable
windows, but were not well received)
I am quite new to interop programming, and do not understand the
concepts well. Please correct me if i am misunderstanding things.
Thanks!

Issue with WPF TwoWay databinding on TextBox hosted in WinForms MDI

I've just discovered recently the source of a problem that has been occurring within an application that I've been working on that uses traditional WinForms MDI with WPF UserControls hosted within ElementHosts for each form. The problem is that if the user changes the text in a TextBox that is TwoWay bound to a ViewModel property that the setter on the property is not set when clicking on the Save button in the toolbar. The consequence of this behavior is that the last text setting that was set is not being saved.
I'm using the default UpdateSourceTrigger value of LostFocus so I believe what is happening is that the the WPF TextBox element is not loosing focus when I click on the WinForms based Save button in the toolbar. So now that I understand the issue I'm curious what the correct or best way is to solve this problem.
The two main options that I can think of either require manual prompting to update the setter without causing the control to loose focus or just make the TextBox loose focus so that the normal source updating occurs.
You can change UpdateSourceTrigger to PropertyChanged, then the "Save" button will work nicely.
I think your reasoning is correct. WPF and Winforms have both seperate "Focusmanagers", so if you go from WPF TextBox to winforms button, then focus has nowhere to go.

WPF UI detach(pin out) functionality

Am looking to implement a detach and popup UI behaviour in my applcation.
It basically means that I will be displaying say, a stackpanel with lot elements on the right side of my page. And on a button click, I want the stackpanel part to popup(removing its allocated space in the UI) and should be able to move it above the underlying wpf UI.
What am trying to do is that remove the stackpanel from its parent grid on button click and add it as the child of wpf popup control. But I am facing some issues doing this way. However I just want to know whether I am doing it in the correct way or do anyone have a good alternative for implementing this pin out functionality am specified here?
Thanks,
Vinsdeon
How about using this kinda nice control, AvalonDock, which is simulating Visual Studio's dockable components behaviors?
http://avalondock.codeplex.com/
It will spare you the pain of developing such a specific functionality, and will have a great reusability anyway

Dynamically adding ElementHost'd WPF UserControl to WinForms results in Black

I have a WPF user control inside an ElementHost that is inside a WinForms control to wrap it. I'm dynamically adding it to a tab control tab.
But when I do this, my WPF control is black.
How do I fix that?
There are many alternative solutions on the web to this one. However, what fixed it for us was to avoid "Fill" docking the element host within it's parent control. If you are using docking, then give it a try!
Unfortunately this can be one of those evil problems solved by experimentation and it'll turn out to be a one line fix!
It was my own mistake. I forgot to add the WinForms tab control panel (a 3rd party one) to the right class.

Need to tab out of ActiveX control in browser

When tabbing through controls in an ActiveX control hosted in IE, once I get to the last control the tab key no longer does anything. I would like it to move the focus outside the ActiveX control to the next html control.
This works fine when the ActiveX control is hosted in a WinForms app, does anybody know how to make this work in the browser?
It may also be relevant that the ActiveX control is a simple wrapper around a WPF control.
I found a hacky solution.
The problem is tabbing out of the WPF control, so I've placed a hidden textbox after the ElementHost within the ActiveX control. Tabbing out of the WPF control moves focus to the hidden control correctly, which upon receiving focus uses SendKeys("{TAB}".
Just typing SendKeys makes me feel a little dirty though, so if anyone has a better solution...

Resources