How to set a prompt for combobox with mixed items? - wpf

There are nice solutions to the problem with combobox and prompt in WPF, but in my case I have mixed items -- image and text. So for example this solution (copied from https://stackoverflow.com/a/11671997/210342):
<ComboBox Name="MyComboBox"
IsEditable="True"
IsReadOnly="True"
Text="-- Select Team --" />
works fine as for prompt, but it has side effect, that when I select an item, the item in turn is not displayed correctly as selected -- it is presented in list OK, but after selection all combobox shows is System.Windows.Controls.ComboBoxItem.
So how to have a prompt (I don't insist of fixing this approach) and properly displayed mixed items?

I solved this in ugly way. I added a grid, put this combobox in the grid with ZIndex=0. I added extra button to the grid with ZIndex=1. This way I get an overlay. Any time users clicks on the button (combo is initially hidden) I open combobox programatically. When users selects anything from dropdown list of the combobox I hide the prompt button.

Related

sap.m.ComboBox - value is cleared, but item is still selected

I have a strange issue with ComboBox:
The control is located in xml fragment, inside sap.m.IconTabFilter.
I select a value in the combobox, then select another IconTabFilter.
Then I return to the previous tab, where the combobox is located.
The value of the combobox is cleared (I see a placeholder again), but when I open the dropdown menu of the combobox, I see that the item I have selected previously is highlighted and I can't select it again, like it's already been selected.
No function runs when switching tabs, no models are refreshed.
I tried to reproduce the issue, but my new code snippet works fine - the value is not cleared when I switch tabs.
What could it be?
Here is one of the ComboBoxes' definition:
<ComboBox id="comboid" items="{path: 'modelName>/'}" placeholder="{i18n>select}" selectionChange="onChange" customData:userProfileSetting="userId">
<core:Item text="{modelName>ID} {modelName>VALUE}" key="{modelName>ID}"/>
</ComboBox>
The root of problem was the low version of sapui5.
After upgrading from 1.28.4 to 1.28.44 (I'm limited to 1.28) it works fine.

Combo Box, More Than One Item In A Row

I'm adding image items to a ComboBox, as you know ComboBox shows just one item in a row, but I want my combo to show more than one, and show images like they are all beside each other with a little space around them, so the user can pick one...
Any Help is pretty much appreciated...
You need to change the ComboBox.ItemsPanel to a WrapPanel.
You would have to edit the ItemTemplate and the ItemsPanel.
Right click the combobox and select Edit Aditional Template --> Edit Generated Items --> Create Empty
Add an image and a text to a Vertical StackPanel in the template and set the bindings.
Now leave the template editing and right click the combobox again.
This time go to Edit Aditional Template --> Edit Layout of Items --> Edit a Copy
Change the StackPanel to a UniformGrid and set the Columns property of this to 2.
The result should look a little like this:
I used sample data in this example. 2 properties: one image, one String(Name).

silverlight combobox - highlight a few items in the popup list

I'm wondering if I can make fake sections in the popup menu:
The rule would be, if the 5th character of the displayed item is different from the 5th char of the previous item in the menu, it has to be highlighted
What do you think?
Thanks!
To achieve this would be a hack.
Normally the items that appear in the popup part of a combo box will be an instantiated data template, and each gets its own data item and has no clue or knowledge of the other items in the list, so you couldn't use a converter or anything else to achieve this behavior.
What you could do though is inject (attach) your own control into the popup part of the combo box, and take over the rendering of the data items. How you do this will depend upon which combo box you are using (i.e. MS or some other vendor's) and would be a whole new question.
Would that be easier if I were to create my own combobox as follow:
a TextBox associated with a Button that when pushed would popup a datagrid in which I could implement this conditional formatting?

ms-access: is it possible to change a combo box to text box using vba?

is it possible to change a combo box to text box using vba?
As an addition to the suggestion about hiding the text box I have seen people use a text box to cover all but the dropdown arrow of the combo box (text box set to be on top of course) and then updated the text box on the after update event of the combo box
I forget why they did it that way in the end but it worked and IMHO is better than hiding the combo box as you might have issues with it still having focus
As far as I know there are two methods. If the form is in design mode then running;
Application.RunCommand acCmdChangeToTextBox
while the combobox is in focus will make it turn into a textbox.
However you cannot do this at runtime. Say you want to show a textbox after selecting a value from the combobox, on the Change event of the combobox you just hide it and show a textbox that was previously hidden. Use the visible property of the combobox and the textbox for this.

Alternative Content for a Selected ComboBoxItem

I need to place a ComboBox in a place where I have very limited space. Is there any way to show content for the SelectedItem in the ComboBox that is different than the content that is displayed for the item in the ComboBox's Popup?
As an example, Firefox does this with it's Site Search box in the top right of the browser. When you open the dropdown, the site names are displayed along with their respective logos, but when a site is selected, only the icon is displayed.
UPDATE: Solution found :-)
I found a solution at this site:
http://blogs.windowsclient.net/airborneengineer/archive/2009/06/25/wpf-styles-and-templates-part-ii-combobox-customization.aspx
I just needed to modify the "DisplayImageWithText" DataTemplate to only show the field I want.
Yes, have 2 sets of data and change the display member column of the combobox - according to the position. as long as the value is the same, it will work good, and you'll get 2 displays out of the same combo-box.

Resources