ComboBox Silverlight - c#

I would like to have the standard silverlightcombobox behave like an html combobox.
So let's say I have a combobox for all states in the US, If I press the 'I' key, it should navigate the selected item to start at the I's ... Is there anyway to do this, it doesn't make sense that it's not built in functionality.
Maybe I missed the memo? Any ideas?

It's not something that comes as standard - even in Silverlight 4 (I hit this very problem today).
However, there are quite a few DIY implementations on the net:
http://gistom.blogspot.com/2009/12/silverlight-combobox-with-keyboard.html
http://www.codeproject.com/KB/silverlight/ComboBoxKeyBrdSelection.aspx
http://www.reflectionit.nl/Blog/PermaLinkd137c1f7-a515-4084-8199-f8b3cf892b8f.aspx
The author of the last post
created a small Behavior which fixes this problem. You can attach the KeyboardSelectionBehavior to a ListBox or ComboBox using Microsoft Expression Blend. You drag it from the Assets and drop it on your ComboBox or ListBox. If you have a custom ItemTemplate you will have to set the SelectionMemberPath property.
If you don't have access to Blend then just use the code as a template and edit the XAML by hand to produce the same result.

Related

C# myListView.Items[0].Selected -- "Selected" isn't defined?

So this one has been driving me a bit batty...
I have a ListView objected which I've created by dragging and dropping from the toolbox onto the graphic window designer area. I've given it a name like "myListView" in the properties panel, and it has worked as expected up until this point (data is being displayed properly, I can graphically select an item and it highlights, etc.)
So today, I am trying to programatically select one of the items in myListView, with the following line of code:
myListView.Items[0].Selected = true;
However, this is giving me a compilation error, specifically that "Selected" is undefined in the object.
Essentially, there is no "Selected" property in myListview.Items[] and I can't figure out why or how to fix it. In fact, there don't appear to be "any" properties at all. Everything I've found on-line seems to confirm that I'm doing this correctly, but, like Alderan, it's just not there. :)
Any ideas?
If you are using WPF, ListView.Items is a collection of objects, hence you don't see any properties. To select the first item in a WPF ListView, you can do this:
myListView.SelectedIndex = 0;

UserControl content not updating

I'm creating a simple UWP application for myself and stuck with lack of understanding of how binding and all that stuff works. Don't know how to explain it better So I created a simple example: https://gist.github.com/anonymous/744dc688d0663a3c14b7a2fc424316f8
The program has a list of selectable items on main screen. I can select several items, press a button and program will show new floating panel, with selected items (And I do further management of these items in my original program). I want this panel to be separate control because my MainPage is already overfilled with code.
The problem is. When I click on the button first time - it works as I expect. But then, when I change selected items and click button again, it shows panel with items from first selection.
My question is - how to do make it work? I have a feeling that it has to be something with INotifyPropertyChanged but cannot understand it.
And I also would be glad to hear the overall recommendations. I'm not c# developer. I'm actually sys. admin but I know a little of python and I learned Delphi 7 in university. So I'm kind of learning c# in process of creation of this application.
UPD: If I change line 28 of SelectedItemsView.xaml from
ItemsSource="{x:Bind SelectedItems}"
To
ItemsSource="{Binding SelectedItems, ElementName=SelectedItemsViewRoot}"
(and add x:Name="SelectedItemsViewRoot" to user control attributes). It works as needed. So new question arrives - is this correct way to do this? I though that Binding is kind of legacy and x:Bind is newer approach that should be used in new apps.
It's ok to use {Binding}, but if you want to stick with {x:Bind}, you can do this with OneWay mode (instead of default OneTime). For example: {x:Bind SelectedItems, Mode=OneWay}.
I strongly encourage you to read these two official tutorials:
Data binding overview and Data binding in depth.
In short, {Binding} is not legacy. It's actually a bit more flexible, but it's performed in runtime, while {x:Bind} is perfmormed at compile time, thus a bit more performant.

How to check where is the control template defined which gets applied to a control

I have a used a control, say ListView, in my custom control. When i run my application i could see that ListView is not rendered in a different way. I suspect that somewhere a control template is defined for listview/listviewitem which resulted in this behavior. I checked the Template property of listview at runtime where i could see childitems are different.
Is there a way to find out that where is this template defined? I understand this sounds like a naive question and i should go thru all the resources and see where i could be present. I tried that but bcoz of complexity/number of the resource items i could not find anything useful.
Thanks

DevExpress Grid App (DXTREME) - How to bind to the ItemNavigationTargetType?

I am working on my first windows 8 application using the devexpress grid app template provided in the New Wizard. Everything is working out fine but however, I would like to bind the MenuItems to specific pages instead of using the ItemsDetailPage for all my menuitems. I have managed to figure out that I need to change the following to the page I want to use:
ItemNavigationTargetType="ItemsDetailPage" to ItemNavigationTargetType="MyPage"
This works fine. I have created another parameter for my menu item which is a "string TargetType". This I use to specify the page the menu item should open. Then I would like to bind this property to the above code to look like the following:
ItemNavigationTargetType="{Binding TargetType}"
But this will not work. Is there another way I can do this. Please assist?
You can use the DXGridView.ItemNavigationTargetTypeBinding property to specify the name of the Page class to be opened when an end-user clicks a DXGridView item.
P.S. I believe the best way to get guaranteed assistance with any DevExpress controls is contacting with DevExpress Support directly. Note that FULL SUPPORT IS FREE during the evaluation period (30 days).

How to create combobox when selected item it adds this anywhere?

How to this for combobox?I have long stackpanel which first it has only combobox.And when i select anything from combobox it will be added as button or other thing like on the picture.And it can be closed
[EDIT] I need anything on WPF
This should do the job nicely in WPF; http://www.codeproject.com/KB/WPF/MultiComboBox.aspx
The combo box that ships with WPF does not support selecting multiple
items...
This article describes a WPF combo box that supports both. It also
describes a list box, which the combo box inherits from, that supports
binding to the SelectedItems
Alternatively: WPF: ComboBox with CheckBoxes as items (it will even update on the fly!)
Recently I’ve come across something weird… I needed a ComboBox that will allow the user to select multiple items.
The the solution coming to mind is using CheckBoxes. I have found several examples, but neither one displayed the selected items with pretty commas like this;
i m not sure what you are asking for but you can use this.
jquery tokenizing
what about this?
jQuery Chosen Plugin
http://davidwalsh.name/dw-content/jquery-chosen.php

Categories