listboxitem

Looping through all items in ListBox?

拜拜、爱过 提交于 2021-02-08 07:54:31
问题 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 whatever value was in that line for populating something else. For example, in my list box I have: 1 2 3 I need to be able to loop through the listbox on button

Looping through all items in ListBox?

ぃ、小莉子 提交于 2021-02-08 07:53:49
问题 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 whatever value was in that line for populating something else. For example, in my list box I have: 1 2 3 I need to be able to loop through the listbox on button

Pulling content from a selected item in a ListBox (urwid)

情到浓时终转凉″ 提交于 2021-01-28 12:20:24
问题 I'm making a ListBox in urwid where each item is a URL pulled from a list of URLs. When an item is selected and ENTER is clicked, I'd like to pull the URL and open it in the browser. Here's my code so far: class SelectableText(urwid.Text): def selectable(self): return True def keypress(self, size, key): return key def handle_input(input): if input == "": # Open link focus_widget, idx = content_container.get_focus() # TODO: Open link from focus_widget elif input in ('q', 'Q'): # Quit raise

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

被刻印的时光 ゝ 提交于 2020-01-24 04:38:08
问题 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, etc. Any help? Cheers, Turtlepower. 回答1: You can find the selected indexes by iterating through SelectedItems and finding the objects in the Items property, like this: List<int>

Set a background image to Listbox item

↘锁芯ラ 提交于 2020-01-23 17:02:13
问题 I'm able to set an image to Listbox using the background property. But how do I set a desirable image as a background to items of the listbox? Thanks. 回答1: You'll have to redefine the ItemTemplate property of the ListBox. If you're not confident with XAML, you should try using Expression Blend. Here is an example of how you're XAML could look like. I created a new application using the Pivot Template application. <ListBox x:Name="FirstListBox" Margin="0,0,-12,0" ItemsSource="{Binding Items}">

Binding the IsSelected property of ListBoxItem to a property on the object from it's source

非 Y 不嫁゛ 提交于 2020-01-20 04:28:10
问题 I have a WPF ListBox control and I'm setting its ItemsSource to a collection of item objects. How can I bind the IsSelected property of the ListBoxItem to a Selected property of a corresponding item object without having an instance of the object to set as a Binding.Source ? 回答1: Just override ItemContainerStyle: <ListBox ItemsSource="..."> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="IsSelected" Value="{Binding Selected}"/> </Style> </ListBox

Binding the IsSelected property of ListBoxItem to a property on the object from it's source

假如想象 提交于 2020-01-20 04:28:05
问题 I have a WPF ListBox control and I'm setting its ItemsSource to a collection of item objects. How can I bind the IsSelected property of the ListBoxItem to a Selected property of a corresponding item object without having an instance of the object to set as a Binding.Source ? 回答1: Just override ItemContainerStyle: <ListBox ItemsSource="..."> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="IsSelected" Value="{Binding Selected}"/> </Style> </ListBox

Binding the IsSelected property of ListBoxItem to a property on the object from it's source

匆匆过客 提交于 2020-01-20 04:28:05
问题 I have a WPF ListBox control and I'm setting its ItemsSource to a collection of item objects. How can I bind the IsSelected property of the ListBoxItem to a Selected property of a corresponding item object without having an instance of the object to set as a Binding.Source ? 回答1: Just override ItemContainerStyle: <ListBox ItemsSource="..."> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="IsSelected" Value="{Binding Selected}"/> </Style> </ListBox

ListBox Foreground Color Problem for Selected Item Without ItemContainer

亡梦爱人 提交于 2020-01-16 18:41:48
问题 alt text http://akashkava.com/blog/wp-content/uploads/2009/12/ListBoxItem-Selection-Problem.png 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 stays in black color, that is because the Item is not its own ItemContainer, however in 2nd case Item is its own

Accessing child of ListBoxItem

我们两清 提交于 2020-01-16 17:59:45
问题 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> </ListBox> I would like to fetch the ComboBox instance in order to manipulate it in the code behind. I found a blog post that explained the process of fetching the ListBoxItem: ListBoxItem lbi = (ListBoxItem)listBox.ItemContainerGenerator