listboxitem

How to get the ListBoxItem for an item in ListBox on "bind-time"

I have a ListBox with Foo objects, and based on some events I disable/enable the ListBoxItems in the ListBox. Using the ListBox.Items property I find Foo objects, and from what I've understood I need to use the following function to get the ListBoxItem container for the Foo. Correct? foreach (var item in Items) { var lbi = ItemCont...

When are ListBoxItems created for ListBox?

I have a ListBox that I bind to an ItemsSource, like this: var foos = new ObservableCollection<Foo> { foo1, foo2, foo3 }; var listBox = new ListBox { ItemsSource = _foos }; Now I want to do some operations right away on the ListBoxItems that holds the items, but they don't seem to be created right away. Are they? Is there some event ...

Silverlight ListBox Height Automatically increase

Hi all, I am using silvelight listbox control,and i stucked.Every listbox item contains another listbox item now when i bind my data second listbox control,it appears horizontal scrollbar and this is not a problem i can remove it.How can do when I add new Item to second listbox,its height automatically increase? For a second listbox Hei...

Binding to property of specific collection item in a ListBoxItemContainerStyle

I have a collection of Company objects contained in a CompaniesCollection which is inherited from Observable Collection. Via a CollectionViewSource, I am displaying these Companies in a list box. One of my requirements is that each company item must show the City and State of the first Address (of a collection of Addresses) attached to...

Stretch ListBoxItem Style Problems

I have a problem stretching the content of a ListBoxItem. I use a DataTemplate with a Grid to place the content of the last column aligned at the right. But I must have something in the basic style of the controls that prevents this kind of display - the "*" ("consume all the rest of space") displays like "auto" ("take only what you real...

Determine the width of the widest element in a ListBox

When you do not explicitly set the width of a ListBox, it will automatically set its width to the width of its widest visible item. This means that as you scroll up and down and the widest visible data item changes, the width of the listbox itself increases and decreases. So what is the best way to find the width of the widest item in t...

WPF ListBoxItem DataTemplate

Hi, I have a list box where I set the items to be in a wrappanel in the ItemsPanel. Essentailly Im trying to have the item scale larger as the mouse moves over the item (Using EventTriggers animation). However since the items are in a warp panel, when they scale, the item is obscured by the next item in the listbox. I have tried chaign...

WPF: Hide ListBox groups when all contents are hidden

I am working on an application that has some ListBox's of information, it is possible that these could hold quite a lot of information (maybe up to 6 or 700 complex items - multiple text fields and images). I used the ListBox control in order to use the grouping, sorting and filtering functionality that you get with it, but it turns out...

losing focus from listboxitem in silverlight

So heres the situation, i have a listbox that has a itemcontainerstyle with a template that contains a usercontrol. Inside this usercontrol is: <Grid Name="Label" MouseLeftButtonDown="Label_MouseLeftButtonDown" > <TextBlock Name="Text" /> </Grid> </Border> <Grid Name="Editor" Visibility="Collapsed" > ...

Getting the index of multiple selected items in a listbox using Silverlight

Hello Stack Overflow, I have a ListBox which is made up of Grid Items in Multiple SelectionMode in Silverlight 3.0. When I use ListBox.SelectedIndex it only returns the first item which is selected. I would like to be able see all of the selected items such that it would return all of the selected item indexes' such as; 2, 5, and 7, e...

Add/Remove items from one ListBox control to another ListBox control in ASP.NET from the client-side

I'm moving itmes from one ASP.NET ListBox control to another ListBox control from client-side. It works on the client-side but when I tried to count items in destination ListBox on the server-side, it's always nothing. Below, is the jQuery code used to add/remove items from ListBox control. <script type="text/javascript"> $(document...

Listbox items become too high for no reason?

Hello the screenshot explains it: Why are do the Items become so tall? I do no positioning myself: <ListBox Margin="6" ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=Segments}"> </ListBox> No ItemTemplate either I'm relying on default ToString() behaviour. ...

Problem with ListBoxItem - produce "System.Windows.Data Error: 4"

Hi. I have craeted the fallowing ListBox: <ListBox x:Name="RecentItemsListBox" Grid.Row="1" BorderThickness="0" Margin="2,0,0,0" SelectionChanged="RecentItemsListBox_SelectionChanged"> <ListBox.Resources> <Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}"> <Style.Trig...

ListBoxItem dynamic style in Silverlight

Is it possible to change ListBoxItem style up to its DataContext property "IsFail" (true, false). ListBoxItem style is defined via VisualStateManager States in ItemContainerStyle. <ListBox x:Name="ShortInfoListBox" Background="{x:Null}" ItemTemplate="{StaticResource ShortInfoTemplate}" ItemCont...

Button inside a listboxitem ignoring clicks when its parent listboxitem is selected

I have a listbox whose listboxitem contains, among other things, a button, as follows: <DataTemplate x:Key="cDataTemplate" DataType="x:Type utils:cd"> <StackPanel Orientation="Horizontal" Background="Transparent"> <Button Style="{StaticResource LIButton}" x:Name="CButton" Command="{x:Static this:EditorComman...

Update WPF ListBoxItem without ListBox.Items.Refresh()?

I have a DataTemplate that I use to display details from a class in a ListBox. The DataTemplate has an EventTrigger attached to the (item) Loaded event that uses a DoubleAnimation to fade each item into view as they are added to the ObservableCollection that is bound to the ListBox. It also has a DataTrigger that uses a DoubleAnimation ...