Alternative Content for a Selected ComboBoxItem - wpf

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.

Related

Compatible value's position in an editable ComboBox

I have a ComboBox implemented with an auto-completion system. My ComboBox contains more than 100 items. When users are typing text in, the auto-completion system opens the dropdown list and highlights the most relevant item. Moreover, when the dropdown list is expanded, all items are available (no filters). But the most relevant item is always at the bottom of the dropdown list.
I would like it to be in the middle, if possible. One item can have the same reference but another type than another one, that's why I need to see most of them in my dropdown by placing them in the middle.
Any idea ? It's not really important but kind of useful for them. Thanks !
Update :
Here's my ComboBox with the open dropdown. Sorry about that, I had to blur its elements. As you can see, the user starts writting the reference in the ComboBox. The autocompletion works fine, but the corresponding item is found at the end of the dropdown list (in the red frame), almost out of bounds.
I wish it would be highlighted in the middle of my dropdown list instead of so far below.
Your item search may work well, but your list isn't visually filtered, which means it's size always remains the same.
It's scrolled into view, by the wpf system, but still displaying all other items around the relevant one. The reason why it's at the bottom is because wpf Scrollviewer just finished scrolling the item into view and sees no need to scroll it further into the middle.
You could use the CollectionViewSource class. Why ?
It's simple to use, will keep your viewmodel data as it is, and you would have your relevant completion item at the top. It can be obtained by GetDefaultView(..)
Let's say you have a viewmodel flag "IsHidden", stating that it's content does not match the user input:
ICollectionView cv= CollectionViewSource.GetDefaultView(myComboBox.ItemsSource);
// switch filter on
cv.Filter = obj => (obj as myViewModel).IsHidden == false;
// switch off
cv.Filter = null

Sencha ExtJS - Display combo picker always on top of the control

So I have this specific combo that I need to display its picker always on top (just as it behaves when it is too near to the bottom of the page). As shown here:
I tried with the pickerAlign config but I wasn't able to put it on top of my control. Thanks!
Found the answer, this will do:
pickerAlign : 'b-t'
Anyway, it displays the same amount of items it would as if there was the same space on top of it that the amount beneath it.

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?

Silverlight - RadTabControl Issue

I am using Silverlight with Telerik Controls.
There is one scenarios where i stuck with it.
1) I have added Tab control into page(XAML page) with two tab Items.
2) I have also added stack panels into both tab items to dynamically add controls into respective stack panels.
3) Then Dynamically added combo boxes into stack panel and these combo boxes are binding with datasource.
4) I am giving bydefault selection functionality for combo by coding, if label name and values of the datasource matching then it will bydefault select perticular item.
5) And finally when i click on the Map button then it will give me two objects with selected comboxes list with respective tabs.
6) When i directly click on the Map buttom then it is giving me proper result.
7) But i did some changes like select some of combo boxes and remove selection from combo boxes then it is givng me correct result of currently selected tab Item. and another tab item shows with zero selction.
8) In this case, i am not able to find controls from another tab.
Can anyone plz help me for a correct way...
Thanks....
Have you posted this to the community forum or posted a support ticket concerning the issue you are having? If possible, please submit a support ticket or post to the forum with the code showing what you are working on so we can look a bit more into the issues you are having.
Thanks!
Evan

Resources