listbox

Double Click a list item

Hello, I have a listbox in my wpf window that binds to an observable collection, now I want to open the browser if someone clicks on an element of the listbox (just like a link). Can someone tell me how to do this? I found something with listboxviews, does it only work this way or is there a way by just using the lisbox? Yours Sebast...

How do I use a Silverlight2 ItemsControl to position a collection of items on a canvas?

In WPF, you can create a ListBox with a Canvas as an ItemsPanel and position items on that canvas. The code to do that looks something like this: <ListBox ItemsSource="{Binding}"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Name}"/> </DataTemplate> </ListBox.ItemTemplate> ...

ASP.NET C# OnMouseOver Event to Make ListBox Appear and Disappear

I have a single webform that has a listbox and a button. When the onmousover event fires the listbox will appear; however on page load, the listbox should not be visible. I have the following code (please excuse the background color changes): Button2.Attributes.Add("onmouseout", "this.style.backgroundColor='Blu...

Select DataList Item to Display in ListBox or Another DataList

Hello, all - first posting. I'm not sure if I am approaching this the right way or if it's even possible. I'm using Visual Web Developer 2008, VB. What I want to do is select a DataList item and have it display on a different part of the page, maybe in a ListBox or another DataList - whatever can display the selected data. That selected...

[WPF] Calculating number of visible items in ListBox

I have a class called Book; class Book { public string Name { get; set; } public string Author { get; set; } public int PagesCount { get; set; } public int Category { get; set; } } The ListBox displays a list of Books and the ItemTemplate has been modified so as to visually represent the Book. The text shows the book's Name, autho...

Programmatically selecting Items/Indexes in a ListBox

In WPF, I'd like to set the selected indexes of a System.Windows.Controls.ListBox I best way I've found so far is to remove all the items from the control, insert the selected, call SelectAll(), then insert the rest, but this solution neither works in my situation nor is very efficient. So, how do you set items in a Listbox to be selec...

Selecting an item from a listbox

I read in a particular site that the code: txtBox = lstBox.ItemData(lstBox.ListIndex()) will provide me with the item that is clicked in the listbox where the ListIndex provides me with the row and ItemData provides me with the data in the row. However on trying to implement it I've noticed that there are no such option for my listbo...

WPF - Why do ContextMenu items work for ListBox but not ItemsControl?

Items in a list have context menus. The context menu items are bound to routed commands. The context menu items work correctly if the list control is a ListBox, but as soon as I downgrade it to an ItemsControl it no longer works. Specifically the menu items are always greyed out. The CanExecute callback in my CommandBinding is not be...

Is there a way to check if a combobox or listboxitem is visible on screen?

If a listbox has many items, is there a way (programatically) to check if an item is visible on screen. For example, the listbox has 100 items, but only first 24 are shown of the screen, is there a way to check if a specific (say list[75]) is currently displayed or one should scroll to see it? ...

How to remove the left-hand blue line on custom selected styled Listbox items?

I found this code which replaces the default select style with a custom style for the select ListBoxItem in a ListBox. However, there is still a little blue line on the left from the default style which I can't remove with any padding or margin changes. How can I remove that blue line and completely determine the style of the selected L...

Get ListBox Displayed Height

Is there a way to determine the displayed height of a Windows Forms ListBox? In an application I am developing, I have a form with a ListBox docked in it. I need to automatically resize the form to remove the any extra space at the bottom which the ListBox does not use due to ListBox.IntegralHeight being set to true. Currently I am si...

WPF Memory Usage

Application: WPF Application consisting of a textbox on top and a listbox below Users type a string in the TextBox to find employees, and search results are displayed in the ListBox ListBox uses DataTemplates to display elements (shows employee name, department, phone and a thumbnail picture.) Implementation: At application startu...

WPF - ListBox Background Color - CodeBehind

Hello, I am attempting to set the background color for a list box in code. I can get it to work with the list box item, but not the list box itself. Here is the code that works (with the ListBoxItem): private void SetBackgroundGradient() { var styleListBox = new Style(typeof(ListBoxItem)); var myBrush = ne...

WPF Listbox display next element after SelectedItem

Hello, I have TextBox and ListBox with bunch of elements. TextBox has KeyDown event handler, the idea behind this is to allow user to press up and down keys to scroll inside ListBox while focus is on TextBox. When user presses "down key" several times, selected element becomes last visible element on screen. If user has reached bottom...

WPF ListBox Selection Problem when changing an item

When changing the selected item in a ListBox, I'm getting a weird error where the changed item appears selected but I cannot deselect it or reselect it. Is there a way to fix this? Here's a sample app that demonstrates the problem. public partial class Window1 : Window { public Window1() { InitializeComponent(); ...

Using Linq To Convert ListBox Items Values to int

I display the contents of a table in the database using a ListBox. Each listbox item is populated with the Text property set to a friendly name, and the Value property set to the unique ID column. The database structure might look similar to the following: CREATE TABLE GENERIC { FRIENDLY_NAME TEXT, ID INT } I tried for almost an hour ...

WPF - Multibinding from Two Sources inside the ListBox DataTemplate

Hello everyone, I tried to look around to see if I am missing something basic, but I can't seem to understand what I am doing wrong. I have a listbox where I would like to bind the itemssource to a collectionview of photos from a dataset. The problem is, I need to take the directory where the images exist from the MasterView Collectio...

High performance Ruby listbox

I need to make a small application in Ruby that will display log lines received over TCP in different colors. What is a recommended GUI framework to use for this type of app? I should work on Windows and Linux. ...

How do I get a reference to the ItemsPanel of a Silverlight ListBox

I've got a ListBox in Silverlight2 that is using a Grid as its ItemsPanelTemplate. In code, how do I get a reference to that Grid? <ItemsPanelTemplate x:Key="GridItemsPanel"> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> ...

DataTextField in a ListBox is a combination of 2 fields.

I have a listbox containing Users. The datasource is an generic list of the type User (contains, id, firstname, lastname, ...). Now I want to use the id as datavalue (through dataValueField) and I want LastName + ' ' + Firstname as a DataTextField. Can anyone tell me how this is possible? I'm using C# (ASP.NET). ...