listbox

WPF ListBox - Getting UIElement instead of of SelectedItem

hi there, i created a ListBox that has a DataTemplate as Itemtemplate. however, is there an easy way to access the generated UIElement instead of SelectedItem in codebehind? when i access SelectedItem i just get the selected object from my ItemsSource collection. Is there a way to access the UIElement (ie. the element generated from th...

WPF ListBoxItem Not Filling

In a listbox, when I select an item I still get some kind of border or space around my listboxitem creating the line you see in the image. I want to remove that line I put a circle around. It already has HorizontalContentAlignment = "Stretch" by the way. What am I doing wrong? The problem: ...

WPF Trigger for IsSelected in a DataTemplate for ListBox items with Blend

I wanted to change the Foreground color when I selected a listboxItem and I did it using this bit of code: <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}},Path=IsSelected}" Value="True"> <Setter TargetName="descriptionTB" Property="Foregrou...

ASP.net listbox control return -1

Hello everyone! I am trying to put a listbox control on my ASP.net page, and when I click it, the selectedindex value is always -1. Why is it doing that? I set AutoPostBack to true. Why is it always returning -1? Please let me know. Thanks ...

WPF Listbox and keyboard navigation

I have a data-bound ListBox with an ItemTemplate which i want to enable keyboard navigation on. If i didn't use an item template and just used the DisplayMemberPath then the list would be navigable with the keybaord. Pressing 'G' for example, would set the selected item to the first listitem beginning with G. Using an item template ob...

TextBox, Button and ListBox in a ListBox

I have a listbox with a bunch of contols in each list item. <ListBox x:Name="projectList" IsSynchronizedWithCurrentItem="True"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Name}" /> <ListBox x:Name="taskList" ItemsSource="{Binding Tasks}"> ...

Resizing font in WPF list or grid to use space properly

I have an application that displays league tables for sporting leagues. These tables are basically grids with different columns representing statistics for each team such as matches played, won, lost, goals scored and concieved etc. As such, a league table has one interesting property: For a given competition, we always have the same amo...

WPF: Listbox, valueconverter

What is the easiest way to use a valueconverter with a listbox? I'm setting the ItemSource to a List<> of objects at runtime, and it displays a textstring from the ToString() method. What I would like, though, is to pass the object through a valueconverter to get a completely different string value. All the examples I have found makes ...

How to insert and display a new row in the string array?

Hi Friends, i want to display a new row in my listbox on my winform. I have a code like this on my backhand class. string[] a = new string[att]; //String array contains the attributes. if (attCol != null) for (int i = 0; i < att; i++) //Loop through entire attributes { a[i] = " Attrib...

Asp.Net ListBox and JQuery

We have a page that contains a ListBox that is disabled (in the codebehind). This ListBox can be enabeled by checking a checkbox on the page; it gets re-enabled with javascript using JQuery. So, the problem is when the control is first disabled then re-enabled on the page, it does not have a selected item even if one is selected. The ...

WPF: Is ListBox or Panel responsible for mouse wheel navigation?

I have a custom ListBox which uses a custom Panel as ItemsHost. I want to have control over mouse wheel input, so that turning the wheel changes the single selected item. I believe that the best method to do so is to handle the OnPreviewMouseWheel event (although this is only have what I want since it doesn't provide horizontal wheel da...

How to detect if items are added to a ListBox (or CheckedListBox) control

This seems like a fundamentally simple question. I have a WinForms dialog box with a listbox. This control is not populated via data-binding but is filled with calls to listBox.Items.Add (obj); It is possible that this call can be made asynchronously from various places and I would like to hook the listbox and watch for changes in it...

WPF ListBox problem with resolution

Hi, I have a WPF ListBox control. It can have a long list of items. When i am working with the normal screen resolution i.e 1024 * 768, it shows the listbox with scrollbar properly, if I mention the MinHeight and MaxHeight for the listbox. and when I switch to another resolution, which is 1280 * 1024, ideally, the listbox should fit to...

Updating SilverLight lists when Bound in-memory collection gets a new member.

I'm trying to pupulate one of three listboxes from a (fourth) source list box. The source has a list of school Subjects which are classified as elementary, middle or high school subjects. The source listbox is a list of checkboxes. The user clicks on the checkbox and one of the other three are intended to get a copy of the Subject obj...

Selecting items in a listbox using C#

Hi, I am using two listbox controls in my wpf window that are identical (identical = itemsource of both the listbox is same and so they look same) and the selection mode on both the listboxes is set to Multiple. Lets call the listboxes LB1 and LB2 for the time being, now when I click an item in LB1, I want the same item in LB2 to get se...

WPF - Animate ListBox.ScrollViewer.HorizontalOffset?

I have a collection of Visuals in a ListBox. I need to find the XPosition of an element inside it and then animate the HorizontalOffset of the ListBox's ScrollViewer. Essentially I want to created an animated ScrollIntoView method. This gives me a couple of problems. Firstly, how can I get a reference to the ListBoxs scrollviewer? Se...

WPF: Aggregating properties on a ListBox

I have two ListBoxes, both use Extended SelectionMode. The ItemsSource of the first is a List, and uses a datatemplate. I'm trying to use an aggregation of some property from the first as the itemssource for the second. For example: public class MultiAppPropertyAggregator : IValueConverter { public object Convert(object value, T...

ViewModel collection bindings in Silverlight

I have two listboxes one with all the projects and one with only active projects. I have one observablecollection with all my projects in it bound to the listbox with all projects. What do I bind to the other listbox? Do I need to create a new collection and sort out the active ones. And when I add a new active project I need to add to ...

Odd problem with ListBox.DataSource

I'm writing a Windows application and using a Listbox control. I'm developing with Visual Studio C# 2008 Express Edition. I've got a data object that looks something like this public class RootObject { public List<SubObject> MySubObjects{ get; set;} } I've got a ListBox on my form, and also a property "MyRootObject" which, obvious...

how to display items in listbox

hi how to display list of items in list box while choose a particular item in dropdown list. ex: thiru is a developer he done some modules. in dropdown list has a list of developers while choose thiru in this list i want to display a what are all the modules completed by thiru that can be listed in listbox I am using Vis...