listbox

Binding Dictionary<T> to a WPF ListBox

Given a dictionary of <string, Drink>, how would you bind the dictionary.Values to a WPF ListBox, so that the items use the .Name property? struct Drink { public string Name { get; private set; } public int Popularity { get; private set; } public Drink ( string name, int popularity ) : this ( ) { this.Na...

How could I make this display for listbox?

Hello everyone, I have a databound listbox which is actually displaying two columns of data. It is displayed as follows: <UserControl.Resources> <DataTemplate x:Key="AlignedPairs"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition...

Sorting Listbox in Silverlight (Sketchflow)

I have a Listbox with multiple columns and bound to a data source (XML) as shown below. <ListBox x:Name="lstBox1" Background="#FFC5EFFD" Margin="7,50,10,15" ItemTemplate="{StaticResource ItemsPanelTemplate1}" ItemsSource="{Binding BPICollection}" BorderThickness="0"/> I'm trying to figure out how to sort a particular column in the li...

Selected item in listbox unreadable because of the color

I dynamically create a collection of stackpanels in my listbox. In this stackpanel are contained labels and checkbox horizontally aligned. The problem is when I click on a stackpanel, the selection is unreadable because the line become dark-blue whereas the letters stay black so black on blue, you see nothing... how can I dynamically c...

Listbox items not selectable

In silverlight, I'm creating a listbox at runtime. The listbox displays on the page okay but the items aren't selectable - I don't understand why? Am I doing something wrong? Here's my code: C# public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); ListBox lb = GetListbox(); ...

WPF - List items not visible in Blend when 'DisplayMemberPath' is used

Hi, We're currently working out how to implement MVVM and I've got to the point where I've got the MVVM Light Toolkit set up in blend and can specify dummy data to be supplied if running in Blend. All good. I've created a dummy list of data. The list contains 6 instances of a very simple class called DummyItem which has Age and Name p...

Databinding a ListBox with SelectionMode = Multiple

I have a WPF ListBox that I would like to Enable multiple selection in the ListBox, and Databind the ListBox to my view model. These two requirements appear to be incompatible. My view model has an ObservableCollection<T> property to bind to this ListBox; I set up a binding in XAML from the property to the ListBox.SelectedItems prop...

how to add folder to a listbox in .net?

i have a list box and i want to add a folder/directory to that which is at the specified location i have used the code string path = "E:\\shruti\\MyDir"; DirectoryItem folder = new DirectoryItem(path); lstBurnItems.Items.Add(folder); //add folder to listbox but its not working fine... what should i do to get success?? ...

How to Set focus on the 1st Item of Nested Listbox in Silverlight?

Hi , I have a List box which contains another lisbox Inside it. <ListBox x:Name="listBoxParent"> <ListBox.ItemTemplate> <DataTemplate> <Image x:Name="thumbNailImagePath" Source="/this.jpg" Style="{StaticResource ThumbNailPreview}" /> <TextBlock Margin="5" Text="{Binding Smt...

KeyDown event is not working for Arrow keys, Home, End, PageUp, PageDown and other similar keys in silverlight.

Hi, I want to override the selection behavior of ListBox Items. We can traverse through ListBox items using Up and Down arrows but I want to traverse the list using Left and Right arrow keys. While I am trying to add the key down event for ListBox, It shows almost all key presses except for Arrow Keys, Home, End and similar keys. I h...

How to Disable the up and Down arrow keys for a silverlight listbox?

Hi, I want to disable the navigation on press of UP and Down arrow keys in Silverlight. I tried with a case statement: void lisBox_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) { int numberofItems = lisBox.Items.Count-1; Keys key = (Keys)e.Key; switch (key) { case Keys.LEFT...

c# GUI changing a listbox from another class

I've written a multithreaded server that uses tcplistener and a client handler class that controls input and output. I also have a GUI chat client. The chat client works fine and the console version of the server also works well. I have a start() method in the partial(?) Form class, which I run from a new thread when I click a button, t...

binding a WPF ListBox SelectedItem to a list

I have a listbox that has its SelectionMode property set to Multiple. Is it possible to bind the SelectedItem property to a List? and not to a single item? Thanks ...

How to disable listbox's click event

I have a listbox which acts as a list of items. If you click on some item, it's contents are shown in the panel on the right (few textboxes etc.). I need to have a validation on these controls as all of them are required fields. And I do have it. The problem is that, even when the validators are not valid, user can click the listbox and ...

Do not show partial items in a WPF listbox

I've tried Google and I've tried Bing to no avail. Does anyone here have an idea on how to prevent partial items from appearing in a listbox in WPF? In case that does not make sense here is an example: Listbox is 200 pixels tall - each item is 35 pixels tall. That means I can show 5.7 items. 7/10 of an item is undesirable. I'd like...

C# Dictionary as a ListBox.DataSource

I am trying to bind a dictionary as a DataSource to a ListBox. The solution in How to bind a dicationary to a ListBox in winforms will not work for me because my dictionary is a class-level variable and not a method-level variable, so I can not use var. When you put a class-level variable into new BindingSource(...) with null as the se...

MS Access 2003 - ordering the string values for a listbox not alphabetical

Here is a silly question. Lets say I have a query that produces for a list box, and it produces values for three stores Store A 18 Store B 32 Store C 54 Now if I ORDER BY in the sql statement the only thing it will do is descending or ascending alphabetically but I want a certain order (only because THEY WANT A CERTAIN ORD...

C# : changing listbox row color?

HI. I am trying to changing backround colorof some rows on listbox.I have 2 list that one has all names and it shown on listbox.And second list has some same value with first list.I want to show that when clicking button it will search in listbox and in second list then will change color where found value. I may search in list box like...

Creating orderable list in WPF using ListBox (HOWTO or better approach?)

I've got a list of things that I want the user to easily edit the order of. Right now I'm binding them to a ListBox with a custom ItemTemplate. Within that template I have an UP & DOWN button. My goal was to move the item up/down based on the button clicked. However I'm having trouble associating the button's click event with the actual...

Cancelling ListBox SelectedIndexChange Event

Is it possible to cancel the SelectedIndexChange event for a listbox on a winforms application? This seems like such a logical thing to have that I must be overlooking some easy feature. Basically, I have been popping up a message box asking if the user really wants to move to another item, as this will change the UI and I don't want t...