I'm trying to create a custom UserControl that will mimic auto-complete as it works within Intellisense using WPF. I'm using a TextBox and a Popup containing a ListBox within my control.
I want to be able to keep keyboard focus set on the TextBox irrespective of whether or not the auto-completion popup is open so that a user can continue typing whilst simultaneously using up/down controls or the mouse to select elements in the popup to autocomplete the text. Is there any way this can be done in WPF?
Check out my article on CodeProject, it addresses the issue of the popup specifically.
A Reusable WPF Autocomplete TextBox
Related
I am working on a simple text editor that allows the user to hover over words in the text and get information about them. I am looking for a way to control a tooltip that pops up based on my own logic the drives from the MouseMove event. Trying to create a simple popup that acts similar to a code editing window when you are debugging and looking at variable symbol values by hovering the mouse over words in the text.
I am not seeing an obvious way to force the tooltip to show/hide on-demand.
Instead of using the ToolTip property, you could use a Popup element and set its IsOpen property to control when you want to display it.
You can style it to look like a ToolTip.
I have several controls in my silverlight view including telerik and my own controls(Custom controls).in this view there is a TextBox called AppointmentSubject which needs to be focused when i open this view.this textbox is also a custom control.I did following thing inside the View_Loaded method.
System.Windows.Browser.HtmlPage.Plugin.Focus();
//TextBoxName.Focus()
AppointmentSubject.Focus();
But AppointmentSubject only gets focused when i open the view second time.Any idea how i achieve it right first time?
I'm developing a VS-Package that shows a WPF window when a MenuCommand is invoked.
inside this WPF window I have a listBox, which is focused immediatly when the window is loaded.
when I show the window via myWindow.ShowDialog(), the arrow up/down key work as expected as I navigate through the listbox items.
However, when I show the window via myWindow.Show(), the listbox gains focus but the keyboard navigation inside the listbox is NOT WORKING, and the PreviewKeyDown event is not firing.
(instead, the caret inside VS editor is moving).
Please help.
Use Microsoft.VisualStudio.PlatformUI.DialogWindow class as the base class for your modal dialog. This should ensure proper keyboard accelerator handling as well as keeping the dialog consistent with the styling of the existing VS dialogs.
I'm developing a custom control which has a button that opens a popup.
When that popup contains another instance of my custom control (which also has a button that opens another popup, e.g. a calendar) some problems occur.
The second (nested) popup won't act as suspected. Clicks don't work, won't close, when parent popup is closed.
Are there any specific best practices when using nested popups?
I had the same issue. We have a custom DropDownSubsetSelector control in our wpf controls library. This control has a Popup in its control template with StaysOpen="False". Today I had to put this control on a custom view that is located inside wpf's Popup control with StaysOpen="False" and was wondered of this unexpected nested Popups behaviour. My workaround for this issue was to inspect Microsoft's source code of a classical ComboBox control. You can find it here Combobox Source. As you can see its behaviour on a Popup control is exactly the same you expect from Popup being located on another Popup, and it's template has Popup inside (dropdown for selectable Items).
You must subscribe to events MouseDownEvent and LostMouseCaptureEvent and deal with mouse capturing for proper handling of MouseDownEvent outside of Popup control's area. Inspect and just copy some source code for your nested ExtendedPopup. You can inherit it from classical Popup.
I have made one custom user control (search text box), which basically consists of one dock panel, and in the panel there are two controls: textbox and button.
I have set some default appearance for this control, which consists of setting a border on the user control, and setting no borders and no background on the textbox, and I have created a custom style for the button. So far this control looks the way I want, and is working correctly.
The problem arises when I want to allow themes for my application. When I put custom styles for basic windows controls (Button, TextBox, ListBox, etc), they are displayed properly with the new theme. But I don't know how to make a template for my custom control. Any attempt ended up in the control not showing at all at runtime.
What exactly must be done in the new template for this control? Do I need to make a template for the User control, and for the textbox and the button controls also?
You are mixing up user controls and custom controls here. What you described above is a user control, and you cannot apply new templates to it.