listbox

What is wrong with this simple binding?

I'm trying to bind a list box in the simplest manner possible with the goal of understanding binding a little better. All examples I see online show data template, and I don't want to get that complicated yet. I have a collection of objects. These objects have a property of string type, and that's what I want to show in the list box. ...

How Can I Remove Items From A ListBox?

This code isn't working. It doesn't raise an exception or even do anything visible. private void RemoveSelectedFiles() { lstPhotos.Items.Remove(lstPhotos.SelectedItems); } How can I remove the selected items from a ListBox? ...

Cannot add items to listbox.

private void DisplayFiles() { lstPhotos.Items.AddRange(files); } files is a List This gives this error: cannot convert from 'System.Collections.Generic.List' to 'object[]' Which makes sense. What should I do? ...

Cannot remove items from ListBox.

When trying to run this method I get an error: List that this enumerator is bound to has been modified. An enumerator can only be used if the list does not change. foreach (var item in lstPhotos.SelectedItems) { lstPhotos.Items.Remove(item); } How can I remove the selected items? ...

How can I have my listbox have columns?

I want my ListBox to have columns, and one of those columns have to be a clickable URL. How can I achieve this? ...

Determine what item was clicked in my ListBox?

How can I determine what item was clicked on my ListBox? ...

How to keep a data-bound list reverse-sorted

I have a listbox bound to a collection. I would like the ListBox to always reverse the order of the items. This handler--hooked up to the control's load event--works for the initial load, but not thereafter. Ive tried using the SourceUpdated event but that doesnt seem to work. How do I maintain a constant active sort? MyList.Items...

Allowing item selection indicator in ListBox to overlay all items in Silverlight

I have a ListBox that uses a WrapPanel for its ItemsPanel, a custom ItemTemplate, and a custom ItemContainerStyle. The ItemContainerStyle's template contains a selection box that shows up when an item is selected. The graphics designer would like this selection box to overlap sibling items in the ListBox like it's an overlay. The firs...

WPF ListBox retain view on SelectedItem on change of Style

Hi, I have a ListBox whose Style and ItemTemplate I change in code-behind on click of specific buttons. listbox.ItemTemplate = FindResource("dataTemplateView1") as DataTemplate; listbox.Style = FindResource("listBoxStyle1") as Style; There are three possible views so there are three sets of data template and style. The DataTemplate c...

Silverlight - Block the screen while the ListBox is rendering using BusyIndicator

I have a ListBox which is wrapped by a BusyIndicator. The ListBox is quite heavy sometimes it could take 4 or 5 seconds to render. I wonder what is the best way to block the UI using the BusyIndicator while the ListBox is rendering? Edit: Sorry I didn't make my question very clear... Please be aware of that the ItemsSource of the ListB...

Binding Errors in DataTemplated ListBoxItems

Currently i have a user control which contains a listbox of other visual element user controls; which (for this special case) have been data templated. <Grid> <ListBox ItemSource="{Binding Path=UserControlCollection}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> ...

Windows Phone 7: Highlight Selected Listbox item

Hi, I have the following XAML (simple list box with custom DataTemplate). I'm trying to figure out how to highlight the selected item (maybe background colour change). I figure I need to do something with Styles in Expression Blend but I'm not quite sure where to start... Edit: After a bit of playing around I now have this (which doesn't...

How to Bind Flags Enums To ListBox In MVVM

Hi, I want to bind an enum which has flags attribute to a listbox with a check list box item template in mvvm pattern? How can I do this? [Flags] public enum SportTypes { None = 0, Baseball = 1, Basketball = 2, Football = 4, Handball = 8, Soccer = 16, Volleyball = 32 } <ListBox Name="checkboxList2" ...

ItemTemplate: ListBox vs ItemsControl

Hi, I'm quite new to the WPF world and I'm having some problems with templating items in an ItemsControl. What I need is to template elements (mostly buttons) inside an ItemsControl (or the like). If I'm using the following XAML code ... <ItemsControl> <ItemsControl.ItemTemplate> <DataTemplate DataType="{x:Type Button}"> ...

System.MissingMethodException: No parameterless constructor defined for this object.

I'm using MVC 2.0 with a Html.ListBoxFor as below: <% using (Html.BeginForm()) { %> <input type="submit" value=">" /> <%= Html.ListBoxFor(x => x.lstTest, new MultiSelectList(new [] {"someone", "crap", "why"})) %> <% } %> When I click the input submit button below with nothing selected, it posts back fine, when I ...

WPF - how to synchronize CollectionView's CurrentPosition with ListBox?

Summary of my question: I am canceling from CollectionView's CurrentChanging event and ListBox still allows highlighting other items (even though the current position doesn't get changed. How can I prevent ListBox from highlighting other items? More details: I have a ListBox showing entities, synchronized with controls to edit it. IsSy...

Counting duplicates in a Listbox

I am trying to develop a simple application in C# to count the number of duplicates in a listbox. I need to count all the number of duplicates and display a rank suffix to the top 3 elements most duplicated. For example, suppose a list has 7 elements called 'apple', 6 elements called 'pear', 4 elements called 'peach' and 3 elements calle...

ASP vbscript problem - disabled listbox control on IE6 and IE8

The problem is I have a vbscript that runs on the server which has the following line: listBoxName.disabled = True When the page is rendered to the browser, on IE6 the html for the listbox control is available, but on IE8 the listbox control itself is missing. On a classic ASP page, when a vbscript is run on the server which disables...

How to align the text in a wx.ListBox using wxPython?

Hello, I want the text of the ListBox to be centered, is that possible? Thanks in advance :) ...

WPF- ListBoxItem border is sometimes hidden behind the ListBox's scrollbar.

Most of the time the ListBox appears like this: But every once in a while it looks like this: Any idea of what is going wrong? --Edit-- I removed the control templates from the question, because when I removed them from my program the problem still existed. Is this a WPF bug? ...