TabStop property is not working for usercontrol inside the panel - c#

I have a usercontrol which is placed inside one panel and some other controls like buttons in another panel. when the usercontrol is active and i move from other controls using tab key, usercontrol gets focus even when the TapStop property for the usercontrol is set to "False".
In another case, when i have the usercontrol placed in the form not inside the panel, usercontrol didnt get focused when moving from other controls using tab key.
Could anyone share me the details why the usercontrol is getting focused when it is only placed inside the panel?
Thanks and Regards,
Amal

Related

Attach button to panel

I created a simple Winform application with a panel and a button on it. when move panel, the button doesn't. Is it possible to attach button to panel so each operation on panel implies operation on button too?
You will want to go to the panel's properties page, find the property “dock” and set it to the option that best suits your needs, probably “fill”. Whatever you do to the panel, will also manage changes to controls docked to the panel.

WinForms UserControl can't Focus properly

I have a WinForms UserControl that accepts keyboard input, and had a Scrollbar for scrolling, and everything was fine. Recently I swapped the Scrollbar control out for a custom scrollbar (also a UserControl), and now after clicking the custom scrollbar, my custom control loses focus and the only way to get it back is to click a different focusable control (like a TextBox) and then click back in my UserControl. If the scrollbar has focus and I click inside my UserControl to give it focus, I notice the LostFocus event is raised and the scrollbar keeps the focus
I tried setting the UserControl's Selectable control style to true, it didn't help.
Any idea why it would behave this way?
I figured it out. I used
SetStyle(ControlStyles.ContainerControl, false);
In the UserControl's constructor. Because it had the ContainerControl flag set by default, it would preferentially give the focus to a child control.

How to activate all the parent(i.e. one tab) of a UserControl in WPF

For an error validation mechanism, I've to be able to "navigate" in my application to one specific pane.
Currently I've one "SelectedNode" and tries to focus the control that is bound to this property(basically, I've an AttachedProperty to set the IsFocus, based on the name).
My issue is that sometimes this page contains tabs. And it appears that the control cannot be focused if it's hidden(not in the active tab).
Is there a way from an UserControl to go up in its visual tree to "activate" all his parent?
I cannot just bind the "SelectedIndex" of my tabcontrol in the viewModel, for a lot of reasons:
The UserControl that has the tab has one sub user control for each tab, so the usercontrol doesn't know what is in which usercontrol
Putting such things in the ViewModel is wrong, the ViewModel should not have to know that it's displayed in tabs or all in the same pane
Thanks!

Silverlight - determine if UserControl is visible to the user

I have a usercontrol in my Silverlight 5 Application. This UserControl can be placed on any other control (perhaps on a TabItem, a Panel etc.). I does now have to determine, if the UserControl is visible to the User. This should only be true, when the UserControl or some region of it are visible to the user. This sould be false for example, when the UserControl is on a TabItem which is in background or the UserControl is on a collapsed panel etc.
Can I get this information out of the VisualTree?
Thanks for any hints.
Setting the visibility can be done with the code below:
MyItem.Visibility = Visibility.Visible;
Normally, when placing an item inside a tabcontrol, the visibility value of it depends on the active tab, changing tabs will result in seeing the tabs value, while not giving the other tabs values.

Triggering UpdatePanel on a button contained within a UserControl situated on the webpage

I would like an UpdatPanel to update it's content once a button is clicked - this button is contained within a UserControl placed on the webpage.
However, I cannot just simply reference it using the AsyncPostBackTrigger's ControlID property, because the button is not situated directly on the webpage.
Is there any way to reference it to the AsyncPostBackTrigger?
Use RegisterAsyncPostbackControl, e.g. if you have a user control UserControl1 containing Button1 and your script manager is called ScriptManager1:
ScriptManager1.RegisterAsyncPostbackControl(UserControl1.FindControl("Button1"));
Edit:
This will refresh all update panels, except panels that have their property set to conditional. For these panels you need to call UpdatePanel.Update(); in the code for the button.
Does the user control expose the button as a child control? If not can it? If not then you can use FindControl on the user control to find the inner button.

Categories