Assume there is a WPF window with multiple textboxes and one button. Currently the cursor is blinking in one of the textBox and then on button click I launched a modal window and then on close of this Window I want the Cursor blinking back to the textbox where it was before launch of the modal window.
How I can achieve it in WPF?
FocusManager.GetFocusedElement
It will give the button, not the textbox.
Related
When I display a Popup all other controls in the background appears to be not active (i.e. when I hover over a button for example it does not change a style). When I click somewhere to dismiss the Popup and it just happens to be a button where I clicked, that button takes a hit. This is very confusing, because one would assume that they can click anywhere to dismiss the popup and not just the empty space.
How to prevent interaction with controls in background when Popup is open?
OR
How to make controls in background react to the mouse hover even when Popup is open (like ToolTip)?
Setting IsHitTestVisible either to true or false seems to have no effect.
I created a custom tooltip that stays open when the mouse hovers over a button by using a popup. My solution is here. You can see the following attachment that displays the popup working correctly. By the way, any mouse event will be triggered on the popup in this state, such as MouseEnter:
For simplicity, hovering a mouse over the popup will trigger the MouseEnter event:
<Popup MouseEnter="TT_Popup_Control_MouseEnter"></Popup>
The issue is when the Child Ribbon Buttons collapse. When I click on the collapsed Parent Ribbon Button to expand the Child Buttons, and hover over the Child Button, I get something like this:
Again for simplicity, hovering a mouse over the popup will no longer trigger the MouseEnter event:
<Popup MouseEnter="TT_Popup_Control_MouseEnter"></Popup>
So when I hover over the popup, the popup no longer stays open in this state. Since the popup mouse events are no longer triggered, I believe this is the issue, but I don't know why this is the issue. Did I discover a bug in the .NET framework? Or is there something I am missing here?
In my mainpage i added around 15 user controls and 10 more button images.Whenever click on particular button image displaying corresponding usercontrol.usercontrol having close button to close that control.my question is if user not closing particular usercontrol and click on another button image it's displaying another usercontrol.How to close previuos usercontrol when click on another button image. general idea we can disabling usercontrols by it's visibilty property when click on other button.But in my case so many usercontrols and buttons are there.it's hectic to write code like that for close previous usercontrols .Any other ideas to close that ?
I have a wondows form which contains a WPF control as well. When I click on the control it brings up a WPF popup control with a listbox. The goal is, when I select an item on the listbox, the windows form will be repopulated accordingly and the popup should get closed. The current implementation with SelectionChanged on the listbox works fine.
Here is the problem. The popup is big and covers some portion of the winform which contains some links. Now, when I select an item on the listbox, the popup closes after doing necessary actions, but if there is a link just below the popup (on the winform) that is under the cursor (when you selected the item on the listbox), that link is also taking the click event.
Is there any way to prevent the links getting clicked when I click on the popup? I have to close the popup though.
I think I figured this out.
SelectionChanged gets executed when we press the mouse key down and before we lift it.(Mouse key up). The popup gets closed in SelectionChanged before we lift the Mouse key. So, when we leave the mouse key, the keyUp event actually gets fired for a link on the Winform as the popup has been closed by now.
I moved the logic from SelectionChanged to PreviewMouseUp and the popup stays till I leave the mouse key and therefore the links on the Winform do not get the event. Of course, I check whether the selection has been changed or not.
I want to make a control which will work like the tab header in Visual Studio 2010.
When you have a few tabs open (MainWindow.xaml, MainWindow.xaml.cs, etc.) only the active tab has a close button visible, but when you hover the mouse over an inactive tab the close button appears, which means you can close any tab with one click.
It probably will be a border with text under the floated buttons.
All WPF controls are containers, you can put a button inside a button for example. You can have a layout manager to a control with the items you want in it.
For what you are asking about you could have a user control that has a TextArea and a Button in a StackPanel. Then hide the button. You then have the user control register for its MouseEnter and MouseLeave events and when the mouse is over you make the button visible, and when it leaves you hide it again.