listbox

WPF: Dynamically change ListBox's ItemTemplate based on ListBox Items Size

I need to change the DataTemplate of my ListBox, based on the ListBox items count. I have come up with the following XAML: <Window.Resources> <DataTemplate x:Key="DefaultTemplate"> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Path=Text}"/> <TextBlock Text="default template" /> </StackPanel> </DataTem...

How do I associate a record with a TListBox item?

I have one record type. I want to add the variable of that record type in TListbox and retrieve it on click event of TListbox. Is it possible? If yes then how? I added it using lstbox.AddItem(data,myrec); It shows error of incompatible types. data is string and myrec is variable of MyRecord which I have created. For adding: N...

Multicolumn ListBox control

I'm looking for a free ASP.NET 2.0 ListBox control that supports display of items in two columns. It also needs to support selecting multiple items. I really prefer not to have to use a monospaced font and mess with formatting my ListBox items into columns. I also saw suggestions to use other types of controls (such as a DataList) but...

asp.net listboxes and XML

I have the following XML <?xml version="1.0" encoding="UTF-8"?> <Releases> <Release version="1"> <Status>Development</Status> <Date>18/8/10</Date> <Features> <Feature Name="Org"> <Developer>someone</Developer> <Deatil>ejfkhwekjfhefhw</Deatil> </Feature> <Feature Name="Export"> <Developer>Some dev</Developer> <Deat...

Silverlight 4 ManagedRuntimeError 4004 Listbox Scrolling Image XamlParseException

Silverlight 4 is crashing on me. The Just-In-Time Debugger says: An unhandled exception ('Unhandled Error in Silverlight Application') Code: 4004 Category: ManagedRuntimeError Message: System.Windows.Markup.XamlparseException: [Line: 0 Position: 0] I bind a listbox to a collection of 20 (or so) items. the collection loads fine and b...

Why the DrawItem method of my owner draw listbox can't be called

I try to write a owner draw listbox with WTL. My code looks like this template class ATL_NO_VTABLE CMyListBoxImpl : public CWindowImpl, public COwnerDraw { ... BEGIN_MSG_MAP(CMyListBoxImpl) MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) ...

Having trouble getting contents of ListBox to resize with it

I tried the suggestion here regarding Stretching, but it didn't work for me. I have a TabItem that hosts a UserControl that is essentially just a ListBox with an ItemsPanel. The ItemsPanel forces the ListBox to display its contents horizontally. The contents of the ListBox are databound to an ObservableCollection<StackPanelContents>, ...

Realtime filtering of listbox

I would like to be able to filter a listbox containing 1000 strings, each 50 - 4000 characters in length, as the user types in the textbox without a delay. I'm currently using a timer which updates the listbox after the TextChanged event of the textbox has not been triggered in 300ms. However, this is quite jerky and the ui sometimes f...

Speeding up listbox insertion time

I need to add 950 strings that are 2500 characters in length to a listbox. The method I am using below takes 2.5 seconds and ideally it needs to happen in less then 500ms. Stopwatch sw = Stopwatch.StartNew(); listBox1.BeginUpdate(); listBox1.Items.AddRange(items.ToArray()); listBox1.EndUpdate(); sw.Stop(); What would be the best wa...

WPF ListBoxItem with value ?

Hi ! I would like you to ask if it is somehow possible to provide in the ListBoxItem the string that will appear and the value to be stored in DB. This is indeed possible: ItemSource={Binding MyEnumColleciton} or ItemSource={DynamicResource MyCollection} etc.. but if you image that I have about 100 ListBoxes .. I don't want to hav...

How to implement substring search / filter in WPF Listbox with highlighting ?

Folks, I am writing a small WPF Windows App which has a listbox bound to Task type objects. I need to be able to search and narrow down the list of Tasks by TaskName. Narrowing down the selection isn't the problem, but bolding the matching characters you typed to narrow down the selection is. For an example if I got tasks "Party" and "P...

"Pause" a scrollbar (in ListBox/etc) from insert/add to ItemSource

Twitter's new UserStream function is awesome, but has one major downside - the noise gets noisier. With updates coming in realtime, often it is hard to read a tweet before the framework scrolls down the tweet out of sight. Ideally, I'd like to pause/stop automagic scrolling if the Listbox focus isn't at the very top, even if it resulted...

how to get the selected object in a listbox ---wpf

i have three listboxes, whose itemsSource is binded to a list, list and dictionary. i want to add the selected user and selected book to the dictionary with a command but i can't take the selected items. i am trying to obey the mvvm. i have a booklist and a userlist in my viewmodel which are binded to the given listboxes in my view. i co...

C# Help displaying listbox item from instantiated object

Hey guys, I have a listbox which the user inputs data into. I then can display the output with a line like this: dest.Text = (string)listBox.Items[0]; Basically, it outputs the the listBox item at location 0 to a textbox called dest. Problem is that I want to be able to do this from a different class so I instantiate an object like so...

WP7 Have the enter key send text from textbox to a textblock.

Hey guys, the following tutorial shows how to take the text from a text box and display it in a text block when the user hits a button. Simple enough... but what I want to do is instead of hitting a button that adds the text I want the enter button to do it. Searching here, I found the following code but it doesn't seem to do anything. ...

sorting listbox in c#

hi, I'm using listbox in c# as a container to a user-defined objects. how can I sort the list by a class member (int) of the objects? ...

Handling double click events on ListBox items in C#

I am trying to do something when double clicking an item in a ListBox. I have found this code for doing that void listBox1_MouseDoubleClick(object sender, MouseEventArgs e) { int index = this.listBox1.IndexFromPoint(e.Location); if (index != System.Windows.Forms.ListBox.NoMatches) { MessageBox.Sh...

White squares in listbox

I have a binded ListBox that displays text. This text is coming from another multiline TextBox. Multiple lines are shown as first line□□second line in ListBox. I want this text to be displayed as first line second line OR as first line in a ListBox row. EDIT: I am actually trying to create a note taking application. The 'ListBox' w...

Binding to images

Hi, I'm using a listbox with a template like the following. <ListBox.ItemTemplate> <DataTemplate> <Image Source="{Binding}" Width="100" /> </DataTemplate> </ListBox.ItemTemplate> I bind this to an observable collection conataining 130 paths to images (all do exist, read out using System.IO.Directory) but only a few ge...

I used the example gave by microsoft to drag and drop an object from a ScatteredView to a Surface List Box but it is not working

Hi, I developped the example given by Microsoft to drag and drop and object from a scatterview to a surface list box. The scatterview is working, I can move the objects on it. But when I try to drag and drop them on the Surface ListBox nothing happen. I posed a breakpoint on the method OnDragSourcePreviewContactDown but it doesn't ent...