Overlay WPF controls - wpf

I've written an 'auto-suggest' textbox user control in WPF. It behaves a little bit like the 'To' list in Hotmail, allowing the user to enter a list of items, offering suggestions when it is able.
The main controls are a a text box, a wrap panel and a list box. The text box captures user input. The wrap panel contains the text box and shows previous entries. The list box is used to show suggestions. Most of the time, the list box is hidden.
I'm using multiple instances of my control in a stack panel.
My problem is that when the list box is shown, it is included in the measurement of the height of the control. This forces the following controls in the stack panel to be shifted down, as these pictures demonstrate:
alt text http://img13.imageshack.us/img13/8366/example1a.png
alt text http://img208.imageshack.us/img208/7664/example2a.png
I've tried overriding the measurement of my control so not to include the list box, but this just results in the list box not being visible.
What I want to do is make the list box overlay any subsequent controls in the stack panel, like a combo box's drop down would do. However, I really don't know how to do this. Any ideas?
Thanks
Sandy

You might want to have a look at the Popup control. That is what the ComboBox uses to display its options. Good luck!

Try this instead of your text box / list box combination: A Reusable WPF Autocomplete TextBox

Related

Changing the data in a specific area of a window, Caliburn.Micro, WPF

Here is my need. I think a user control is what I need but I am not sure if its the best or even how to use it.
What I have. My main window has a menu with a "help" menu. When you click help, a new window opens, I have a column, At the top of the left column has a drop down box of "Major Titles", a ListBox below that that populates based on the combo box selection. This will be about 25% of the window width. All this works.
When I select an item in the list box a page,contentControl or user control is displayed to the right with verticle scroll bars so the window does not need to resize, the information I display that changes based on the list box selection will have only visuals like text block, label, images. There will be no user interaction with the changeable pages Just formatted Data.
What would be the best way to approach this? Can anyone offer an easy example?
I was thinking of using a user control and change the user control based on the selected list box item.
Ok, I got this figured. After reading a lot of posts and blogs. Seems people sometimes want to make things more complicated then they actually are.
What I wanted, a permanent list box on the left 1/6 of the window. The list box contained string names for "help subjects". On the right 5/6 of the screen I added a groupbox with header and in group box I added a usercontrol. The content of the control is bound to a property called 'ActiveView'. The list box selected value property is bound to 'SelectedListItem' property.
When you change it set 'SelectedListItem' a method is called 'SetActiveControl'. SetActiveControl has a switch/case that sets like in the example:
``Case "Setup":
ActiveView = new SomeSelectionViewModel();
Break;
I have created a user control in a folder inside the Views folder called HelpControls, I also created the same folder in ViewModels. I have classes matching the user controls and everything is bound together.
Ultimately when you click the list box item, the associated ViewModel is called and in turn populates the user control on the window with the appropriate data.
I need to later look into, using one ViewModel for all the controls, I know that can be done using Cal:Model.View = ViewModel name. In the xaml of the control. I'm just not sure how to call the appropriate user control view when an item is selected. Either way this would become a view first design and I thought I read, Caliburn. Micro was intended as a ViewModel first design.

Multiline Combobox Control in WPF

I would like to build a multiline combobox in WPF. This would be similar to label control wherein the width of control will grow such that entire selected text is visible. The text displayed can go over next line if there is no enough space available on current line.
I tried few things around control template of combobox. But still no success.
Below is sample screenshot of how it should look like!
Any pointers?
Thanks,
Sambhaji
As per my understanding setting the control template for this particular scenario would be a tedious job. I would have created a TextBlock and tried setting the event triggers which will open a container on mouse hover or click event.

Add CheckBox as Bullet inside RichTextBox

I was wondering if it was possible to create a list that has check boxes in place of bullets.
I want to create a lengthy list of questions inside RichTextBox and would like it to automatically place a small check box prior to each question. Much like it would place a bullet after each time I press 'enter'. I don't see a check box as an option in the list of bullets.
WPF RichTextBox doesn't support checkbox as bullet. For your requirement you need to add check box as InlineUIContainer in RichTextBox.Here is sample to play with flowdocument

How to position a menubar above TextBox in Silverlight?

I want to add the menubar to TextBox control in Silverlight 4. (I will create a new reusable control.) The menubar will consists of a few image buttons. The idea is that it will normally stay hidden and will show up only when the user puts his/her mouse cursor to the TextBox area. If used in a multiline textbox, whole menubar can fit inside it, this should be easy. (I hope. :-))
But how to solve situation when TextBox is in single line mode? I'd like to put the menubar above the TextBox. But I don't have a clue how to do it. Can somebody help? I need to let all other controls in a form to stay in their positions, and only add my menubar above my textbox. (So the menubar will NOT hide the textbox. Instead, it will hide other controls residing right above the textbox.) It should work in all arrangements of form, like Grid, StackPanel, Canvas etc. In the fact it would be similar to a classic right-click context menu, but not modal. (Right-click context menu is modal, i.e. while it is shown you cannot use other controls, and it automatically hides when you click anywhere else. I want my menubar to stay visible as long as user heeps mouse cursor over the textbox or the menubar.)
Example: Coordinates of textbox are top=100,left=20,bottom=115,right=120. So my menubar's coordinates should be bottom=100,left=20, right & top are based on size of menubar.
If many textboxes will be used on a single page, each single one should have its own menubar. (Of course.)
You can create your own control (custom control or UserControl, whichever you like should work) which has the TextBox, and the visual for the menu bar.
If the TextBox is single-line, you could display the menu bar in a Popup which you position just above the TextBox whenever the mouse is over it.
If the TextBox is multi-line, you'd simply use a StackPanel or Grid or whatever to do layout like normal, if I am understanding what you want.
No coding required if you use this menu:
http://sl4popupmenu.codeplex.com
To achieve this behavior you will need to set its IsPinned property to true.

Silverlight light dropdown

I have a Silverlight form that contains a Stack Panel (orientation = vertical) with 10 rows. Each row contains a TextBlock and Textbox control except the last row has a TextBlock and Drowdown.. At the bottom of the control are two buttons. Previous & Continue.
There are 10 items in the Dropdown. When I select a value from the Dropdown, only two of the ten items are showing up. I believe that the remaining items aren't displying because there's some sort of clipping effect going on. Fair enough.
Does Silverlight allow the dropdown control to display upwards (instead of the default down direction)? Will I have to override some rendering capabiliities before the dropdown is rendered to the control or is there a property that allows me to accomplish this functionality?
The Silverlight ComboBox auto aligns the dropdown popup to always be visible whenever possible.
all Popup based controls (ComboBox, AutoCompleteBox, DatePicker and TimePicker) all have this feature enabled.
So if there's not enough screen real-estate below the ComboBox to show the dropdown popup, it'll show up above the control.
The combobox nesting in the visual tree should not affect the dropdown popup auto alignment. The internal Popup control (inside the ComboBox) ignores the Visual Tree and is nested "above" the visual tree.
If you have specific issues, please share minimal and relevant XAML. Since Keith is on this thread, I think it's safe to say he'll log a bug if needed.

Resources