WPF – add static items to a combo box

Here is the code from MSDN and the link – Article Link, which you should check out for more detail. <ComboBox Text=”Is not open”> <ComboBoxItem Name=”cbi1″>Item1</ComboBoxItem> <ComboBoxItem Name=”cbi2″>Item2</ComboBoxItem> <ComboBoxItem Name=”cbi3″>Item3</ComboBoxItem> </ComboBox>

jQuery “on create” event for dynamically-created elements

You can on the DOMNodeInserted event to get an event for when it’s added to the document by your code. $(‘body’).on(‘DOMNodeInserted’, ‘select’, function () { //$(this).combobox(); }); $(‘<select>’).appendTo(‘body’); $(‘<select>’).appendTo(‘body’); Fiddled here: http://jsfiddle.net/Codesleuth/qLAB2/3/ EDIT: after reading around I just need to double check DOMNodeInserted won’t cause problems across browsers. This question from 2010 suggests IE doesn’t … Read more

Editable ComboBox with binding to value not in list

I was just doing this yesterday and today and it looks like the following: set the combobox IsEditable=”true” instead of binding to SelectedItem, bind to the Text property of the combobox if you’re binding to a custom object instead of just strings, you need to also set TextSearch.TextPath=”NameOfField”. This lets the text search behavior work, … Read more

HTML combo box with option to type an entry

Before datalist (see note below), you would supply an additional input element for people to type in their own option. <select name=”example”> <option value=”A”>A</option> <option value=”B”>B</option> <option value=”-“>Other</option> </select> <input type=”text” name=”other”> This mechanism works in all browsers and requires no JavaScript. You could use a little JavaScript to be clever about only showing the … Read more

How can I make a WPF combo box have the width of its widest element in XAML?

You can’t do it directly in Xaml but you can use this Attached Behavior. (The Width will be visible in the Designer) <ComboBox behaviors:ComboBoxWidthFromItemsBehavior.ComboBoxWidthFromItems=”True”> <ComboBoxItem Content=”Short”/> <ComboBoxItem Content=”Medium Long”/> <ComboBoxItem Content=”Min”/> </ComboBox> The Attached Behavior ComboBoxWidthFromItemsProperty public static class ComboBoxWidthFromItemsBehavior { public static readonly DependencyProperty ComboBoxWidthFromItemsProperty = DependencyProperty.RegisterAttached ( “ComboBoxWidthFromItems”, typeof(bool), typeof(ComboBoxWidthFromItemsBehavior), new UIPropertyMetadata(false, OnComboBoxWidthFromItemsPropertyChanged) … Read more

ComboBox- SelectionChanged event has old value, not new value

According to MSDN, e.AddedItems: Gets a list that contains the items that were selected. So you could use: private void OnMyComboBoxChanged(object sender, SelectionChangedEventArgs e) { string text = (e.AddedItems[0] as ComboBoxItem).Content as string; } You could also use SelectedItem if you use string values for the Items from the sender: private void OnMyComboBoxChanged(object sender, SelectionChangedEventArgs … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)