listboxitem

How to set ContextMenu of a bound item?

I am trying to achieve the following: <Style TargetType="ListBoxItem"> <Setter Property="ContextMenu"> <Setter.Value> <ContextMenu> <MenuItem Name="mnuEdit" Header="_Edit" Click="MenuItem_Click" /> </ContextMenu> </Setter.Value> </Setter> <Style> But it throws the followi...

WPF: Controlling ListBoxItem height inside wrap panel

Hi All, I have defined Wrap Panel as ListBox Items template <Setter Property="ItemsPanel"> <Setter.Value> <ItemsPanelTemplate> <WrapPanel /> </ItemsPanelTemplate> </Setter.Value> </Setter> I have 3 ListboxesItems per row My ListBoxItem expands when ...

How to add toolbar to bottom, top, left, or right of the inside of a listbox in WPF?

I have a listbox with a style that has rounded corners. I'd like to add a toolbar inside the listbox that pertains to that specific list box. Currently, if I add a toolbar inside the grid that contains a listbox, it will overlap the last item in the row (depending on the height of the toolbar). Does anyone have any ideas on the best w...

Looping through all items in ListBox?

I have a list box which is populated by this code: lstOutcome.Items.Add(lstMap.SelectedItem.Text); In the listbox lstOutcome, I need to be able to loop through the listbox and be able to take the value of the first,second, etc, list items. The reason I need to loop through each line and grab the value of that line is so I can use wh...

Change ListBox item style at run-time

I have a listbox where the items are styled using a ResourceDictionary style which is then attached to the ItemContainerStyle property. This gives my ListBoxItems a BorderThickness of let's say 1. Now I want to collapse the items individually, so I use Visibility.Collapsed but for some reason the border that the ItemContainerStyle has c...

Accessing child of ListBoxItem

I have a ListBox with a DataTemplate that looks like this: <ListBox Name="listBox"> <ListBox.ItemTemplate> <DataTemplate DataType="x:Type local:NumericIconDefinition"> <Grid> <ComboBox Name="IconComboBox"/> </Grid> </DataTemplate> </ListBox.ItemTemplate>...

How can I make listbox transparent, but listbox items opaque in WPF?

Hi, I'm trying to create a transparent ListBox in a WPF application. I want the ListBox to be completely transparent, thus a background image is visible "behind" the ListBox. However, I want my ListBox items to be totaly opaque, that is to say, they lay on top of the background image. Do anyone know how I can accomplish this? Thanx i...

Themed WPF ListBox-Object looks different than ListboxItem?

Hi ! When I use a Theme like link text in my WPF App, I notice a difference between the Items of ListBoxes and ComboBoxes: When I add a an object of my own class to their Items Collection, the created item looks themed. If I make my own class inherit from ListBoxItem/ComboBoxItem, the resulting Visualization looks unthemed. How can I d...

WPF Commands Buttons ListBoxItems

Hi, I Have a listbox defined like below : <ListBox x:Name="lstMedias" ItemsSource="{Binding Medias}" Width="Auto" Height="Auto"> <ListBox.ItemTemplate> <DataTemplate> <Button Content="{Binding Name}" Tag="{Binding Name}" Click="Button_Click" Command="{Binding Path=LoadSimpleMoviePopupCommand}"> <...

WPF Listboxitem not aligning items properly

Ok I got the following DataTemplate: Style="{StaticResource LBStyle}" HorizontalContentAlignment="Stretch"> <ListBox.ItemTemplate> <DataTemplate> <Grid > <Grid.ColumnDefinitions> <ColumnDefinition Width="1*"/> ...

How to determine index of current ListBox item from DataTemplate?

I have a ListBox. Now I want to write a DataTemplate in such way, that the first item will have red background and white background for other items. I guess I need to write a DataTrigger, but I have no idea how do determine that DataTemplate is applying to the first item. ...

How to display in each ListBoxItem textblocks with binding to a filelds of a different tables

Greetings to all and sorry for my English! I have a ListBox, it's ItemsSource = myClientsList.DefaultView. The Items of ListBox have a template (ControlTemplate), that is defined in a in a separate resource file. Every Item contains a little TextBlock's, Text -property of each have a binding to fields of my Object myClientsList. I need ...

Silverlight ListBox OnMouseOver event

I have a ListBox that is being bound to data from a WCF service. When the user hovers over one of the ListBoxItems, I want to display related text in a separate region. Each of the items in the data collection to which the list is being bound has a Description property. How can I wire up to the mouseover event for a particular ListBo...

Disable a single wpf listbox item

Does anyone know if and how one can disable one or more listbox items in a wpf lisbox without disabling the entire listbox? Preferably I would have a DataTrigger which, when a certain Binding value is false, disables this item (make it impossible to select) while keeping other items in the same listbox active. <ListBox> <ListBox.Item...

ListBox Foreground Color Problem for Selected Item Without ItemContainer

The following code, behaves little strange. <ListBox SelectionMode="Multiple"> <StackPanel> <TextBlock>Selection is Black</TextBlock> </StackPanel> <ListBoxItem> <StackPanel> <TextBlock>Selection is White</TextBlock> </StackPanel> </ListBoxItem> </ListBox> Note that first selection stay...

NSIS: How to add Items to a listbox control?

How to add items to a listbox control at run time in NSIS? ...

Wpf Listbox Listboxitem

I have a listbox that uses a datatemplate. What I need is a way after the item is selected I want to shrink the listbox itself, not the listitem inside. I have tried the eventtrigger on the selector.selected and unselected but it doesn't fire. I also put a datatrigger on the datatemplate but I cannot access the listbox from here. Any Ide...

WPF TreeView not collapsing its formerly used space on collapse of root root

Hello, I have some objects with various collection properties that I'm displaying in a ListBox using a DataTemplate for the ItemTemplate. Within that DataTemplate is a TreeView which displays various properties as TreeViewItem children of a root TreeViewItem which represents the items being displayed in the ListBoxItem. My problem is ...

WPF listbox datatrigger hide selected

I have a listbox which has a datatemplate. Within the template I've got a trigger to hide a lsitboxitem if it's IsDeleted property is set to true. <DataTrigger Binding="{Binding Path=IsDeleted}" Value="True"> <Setter Property="Visibility" Value="Collapsed" /> </DataTrigger> This work OK but the problem I have is that the listbox its...

ListBox Item increase when postback

Hi all I made a web part use ASP.NET. There are a listbox and two buttons on it. When you click the Button A, it would add a new item into the listbox.When clicking the Button B, it would postback the list items data. But when you click the button B, the number of listbox number becomes twice. Does anyone meet this problem before? Best...