listboxitem

WPF: Update a label in a listbox item.

I have a ListBox where the number of items is added based on and integer property set by a user. The items are created from a ControlTemplate resource that which is comprised of a Label and a TextBox inside of a DockPanel. The label is not data bound but I would like for it to have somewhat dynamic content based on the (index + 1) of the...

Animate ListBoxItem from one ListBox to another ListBox

I would like to create a visual effect when an item in a listbox is double clicked. So far I have drag and drop functionality where the item is visually attached to the mouse and can be moved to a drop target. From that functionality I am able to animate the item using the same logic of getting the item container, however I am not able t...

Wpf style resource for foreground color of selected listbox item.

Background: I am creating a custom listbox that has radio buttons on each listbox item, so essentially it will be a RadioButtonList. The control is created entirely in code. As of right now the control renders and behaves correctly and supports 2 orientations (Horizontal/Vertical). The listbox uses an ItemTemplate that is a StackPanel wi...

WPF - How to combine DataTrigger and Trigger?

NOTE I have asked the related question: How to combine DataTrigger and EventTrigger? I have a list box containing several items. The item's class implements INotifyPropertyChanged and has a property IsAvailable. I use that property to indicate unavailable options in the list using a different colour. However, if a selected item i...

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...

WPF ListBoxItems with DataTemplates - How do I reference the CLR Object bound to ListBoxItem from within the DataTemplate?

I have a ListBox, that's bound to an ObservableCollection. Each ListBoxItem is displayed with a DataTemplate. I have a button in my DataTemplate, that when clicked, needs a reference to the member of the ObservableCollection it's part of the DataTemplate for. I can't use the ListBox.SelectedItem property because the item does not become...

WPF ListView Inactive Selection Color and element font color

Hello, I'm able to set ListView Inactive Selection Color I used solution described in following question http://stackoverflow.com/questions/382006/wpf-listview-inactive-selection-color I need to change font color of selected inactive element, is there easy way to accomplish this? Thank You ...

WPF ListBox Selection Color

Sorry if this has been asked before, but I couldn't find a solution to what I'm looking for in the related questions that popped up, or on Google. In my application I'm trying to recreate Words New Document dialog, list on the left of items and on the right an icon with text underneath. In Word it has the orange gradient when you mouse...

Unable to set focus on a ListboxItem

Hi, I have a listbox whose ItemSource property is bound to a ViewModel. This ViewModel has an ICollectionView property which is a collection of custom objects. I am loading this collection view as a tree structure in the Listbox. My requirement is to use the arrow keys to navigate along the tree view. I wrote the code to collapse an ite...

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 get a ListBox ItemTemplate to stretch horizontally the full width of the ListBox?

I want to have the ListItems to extend with their orange background the full width of the Listbox. Currently they are only as wide as the FirstName + LastName. I've set every element I can to: HorizontalAlignment="Stretch". I want the background of the ListboxItems to expand as the user stretches the Listbox so I don't want to put in ...

[WPF] ObservableCollection and ListBoxItem DataTemplate generation problem

Something strange is going on with ObservableCollection. I have the following code: private readonly ObservableCollection<DisplayVerse> _display; private readonly ListBox _box; private void TransferToDisplay() { double elementsHeight = 0; _display.Clear(); for (int i = 0; i < _source.Count; i++) { DisplayVerse verse = ...

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...

How to animate ListBox Items on MouseEnter and MouseLeave events using C#/WPF?

I can't capture/trigger OnMouseEnter or OnMouseLeave events through C# code for list items. To be clear, I don't need an OnSelectedItem event. What I want to do is to be able to handle the OnMouseEnter and OnMouseLeave events for ListBoxItem which will start the DoubleAnimation for that ListBoxItem - I want to enlarge its font on Mouse...

Animation stops when ListBoxItem not visible (WPF)

Hello, I have animation on list box items. When the list box item is not visible, ie. scrolled past visible in the listbox the animation seems to stop. When it is scrolled back into view it appears to start where it left off. Does anyone now how to keep the animation running? Thanks ...

WPF ListboxItem loaded multiple times

I have a trigger on a storyboard for my listboxitem where the trigger is 'Loaded'. It appears that every time the listbox scrolls the item gets the 'Loaded' event. I really only want the storyboard to run once, when the listboxitem gets displayed. I assumed that the Loaded event would only get triggered once. Any help would be great. ...

Multiselect WPF Listbox Make Multiple Selections With a Single Click

Hi, I have a databound multiselect listbox bound to a datatable. When I select a listboxitem I want some other listboxitems in the same listbox to be selected automatically. I want multiple items to be selected with a single click. How can i do that? I can't do it in SelectionChanged event because it leads to calling the same event again...

Split the width evenly between of two controls that make up a listbox item?

Hi, I'm trying to setup a ListBox so that every item has a textblock and a combobox, split evenly across the width of the listbox but I can't seem to find the magic combination of ColumnDefinition properties to do it. Here's my DataTemplate for the listbox item. I've cleaned it up since it was wrong, anyhow. <DataTemplate x:Key...

How to capture a mouse click on an Item in a ListBox in WPF?

Hi ! I want to get notified when an item in a ListBox gets clicked by the mouse, whether it is already selected or not. I searched and found this: (http://kevin-berridge.blogspot.com/2008/06/wpf-listboxitem-double-click.html see the comments) private void AddDoubleClickEventStyle(ListBox listBox, MouseButtonEventHandler mouseButtonEve...

Get visual underlying ItemTemplate of an ItemsControl in ContextMenu.MenuItem.Click event handler?

Hello! First take a look at my code: <ListBox ItemsSource="{Binding}" SelectionMode="Multiple" ItemTemplate="{StaticResource ContactTemplate}"> <ListBox.ContextMenu> <ContextMenu> <MenuItem Name="mnuEdit" Header="_Edit" Click="MenuItem_Click" /> </ContextMenu> </ListBox.ContextMenu> </ListBox> ...