listbox

Add image to listbox

Hi, I have a few images with some text, I need to show the image with the relevant text in a listbox. Browsing google I came across this sample class, public class Customer { public string Fname; public string Lname; public Customer(string firstName, string lastName) { Fname = firstName; Lname = lastName; } public overri...

Create custom generic list with bitmapimage

Hi, In my WPF project there is a listbox in which I have to display images and next to each image their text (for example : date the photo was taken, location etc). I have tried creating a generic List but I still can't assign it to the listbox Something like Bscially I have been trying something on this lines. public class LoadImage...

Hide content in listbox item depending on a binding property in Silverlight

I have xaml that lookes like this <ListBox> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Name}" /> <StackPanel Orientation="Vertical" x:Name="contentPanel" > Content goes here... </StackPanel> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> The listbox binds to an object with a...

How to obtain selected items in a checklistbox

I have in a page a databound checklistbox which is populated with data on OnLoad page's event, and also a button. If the user clicks the button, I must recolect the checkboxes selected inside the checklistbox and do some processing. But when I iterate over the checklistbox items collection all items have their Selected property set to...

Dual list drag drop control

Does anyone know of a good .Net2.0+ compatible dual listbox control that either offers dragging and dropping between lists, or simple buttons to move items between lists and also sort the items in a particulr list. This is for a web based app and I would prefer some nice javascript to make this one speedy. ...

Moving keyboard focus away from listbox

Hi! I'm developing a program in WPF (VB) that relies on keyboard navigation only. In my program, I have a listbox that displays up to 20000 items. What I want is that when the listbox has keyboard focus, and I move to the bottom item that is visible (using ArrowDown), I want the focus to move to the next item outside the listbox. I'm...

Silverlight Databinding one control to another

I'm working in Silverlight. I've got a ListBox that's being loaded dynamically. In the listbox, i want to put a checkbox that's tied to the listbox's "selected" property. I can't quite figure out how this is done. Can anyone point me in the right direction? If this were a winform thing, I would, create "OnChecked" handler for the chec...

Is there a way to iterate in a ListBox Items templates?

I have a list box that contains items that are represented by a single textbox. When the user clicks a button, I want to iterate thru all these text boxes and check if their binding expressions are clean of errors; Should be something like: Dim errCount = 0 For Each item In MyListBox.ListBoxItems 'There is no such thing ListBox...

DrawItemEventArgs' "Index" property goes negative sometimes(C#)(RESOLVED)

Hi. I have an owner-drawn listbox control in my project. The problem is that sometimes the DrawItemEventArgs argument passed to my DrawItem event-handler has an Index property of "-1". It seems that this only happens when I scroll through the list box and then try to close my application; To avoid getting an exception I did something ver...

Why can't I set the Opacity in this situation?

Here's the situation... at the top level, I have a TabControl. Each page in the TabControl consists of a ListBox: <TabControl> <TabItem Header="item 1"> <ListBox> <ListBoxItem>sub item 1</ListBoxItem> <ListBoxItem>sub item 2</ListBoxItem> <ListBoxItem>sub item 3</ListBoxItem> </Li...

WPF Listbox: Change selected and unfocused style to not be grayed out

I have a really simple WPF ListBox with SelectionMode set to Multiple. <ListBox SelectionMode="Multiple" /> When the ListBox loses focus it's really hard to tell what's been selected because the selection colour changes from blue to a light grey colour. What's the easiest way of changing this behaviour so that it stays blue? I know i...

WPF listbox empty datatemplate

I was wondering how people handle a ListBox control that has no items? e.g. I want to bind a list of search results but if no results are found i would like to display "No results found". The way i currently tackle this is that i hide the listbox if the result set count = 0 and show a label with the "No results found" message. Ideally ...

WPF ListBox SelectedItem sometimes is not visible (scrolling is out of sync)

Hello, I have a Listbox that is filled with 30,000 elements <ListBox Name="lbWordlist" Grid.Row="1" Margin="10" ItemsSource="{Binding Source={StaticResource WordListViewSource}}" SelectedItem="{Binding Source={StaticResource MainViewModel}, Path=SelectedArticle}" IsSynchronizedWithC...

Preserve listbox item selection

Hi, First the code (sorry if its not 100%) I am no expert and then the question follows. public partial class Window1 : Window { CollectionView cv; public Window1() { InitializeComponent(); List<Person> ppl = new List<Person>(); BitmapImage b = new BitmapImage(new Uri(@"http://i.stackoverfl...

Compare different ways to remove selected items from System.Windows.Forms.ListBox

So far I've found 2 ways to delete selected items from a listbox (winform): 1. ListBox.SelectedObjectCollection tempCollection = new ListBox.SelectedObjectCollection(myListBox); for (int i = tempCollection.Count - 1; i >= 0; i--) { myListBox.Items.Remove(tempCollection[i]); } 2. while (myListBox.SelectedItems.Count > 0) { my...

Scrolling a listbox with page up/down

I had an ItemsControl, which you could use page up/down buttons to scroll expectedly. I switched it with a ListBox, to apply (thru triggers) a new DataTemplate when an item is selected. Everything works fine, until using pageup or pagedown buttons. Instead of scrolling one page, it scrolls till the end or the beginning. My previous a...

Win32 LB_GETTEXT returns garbage.

Hello, I have a problem which is most likely a simple problem, but neverthe less still a problem for me. I am using the Listbox in Win32 / C++ and when getting the selected text from my listbox the string returned is just garbage. It is a handle to a struct or similar? Below is the code and an example of what I get. std::string Listbox...

Sort WPF ListBox on button click?

First off let me just say I'm very new to coding so there are big gaps in my knowledge... anywho: Right, I'm trying to sort a WPF listbox when a button is clicked, preferrably in pure xaml (otherwise VB). I'm having a hard time seeing as most samples are written in C#. Here's my code: <Grid.Resources> <CollectionViewSource x:Key...

Numbered listbox

I have a sorted listbox and need to display each item's row number. In this demo I have a Person class with a Name string property. The listbox displays a a list of Persons sorted by Name. How can I add to the datatemplate of the listbox the row number??? XAML: <Window x:Class="NumberedListBox.Window1" xmlns="http://schemas.microso...

Silverlight 3: ListBox DataTemplate HorizontalAlignment

I have a ListBox with it's ItemTemplate bound to a DataTemplate. My problem is I cannot get the elements in the template to stretch to the full width of the ListBox. <ListBox x:Name="listPeople" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0,0,0,0" Background="{x:Null}" SelectionMode="Extended" Grid.Row="1" ...