listbox

WPF listbox item not wordwrapping

我的未来我决定 提交于 2019-12-04 17:35:44
问题 My ListBox has, amongst other things a description field in it which can be quite long. Instead of having a horizontal scroll bar I want to word wrap it. It works if I set the MaxWidth but since the ListBox changes size I don't want to hard code the value. What's the best way to do this? EDIT: The description is in a TextBlock . Simplified XAML (Removed unnessesary stuff, still shows problem: <ListBox BorderThickness="0" Padding="5" Name="lstTasks"> <ListBox.ItemsSource> <Binding Source="

How to highlight selected item in list box windows phone?

瘦欲@ 提交于 2019-12-04 17:26:40
I am developing a windows phone application. I placed list box control in my app and displayed a list. I need to highlight the selected row with a blue color. How can I do that ?. I tried a code. But its not working. I add the code I used below. Please help. <ListBox Margin="0,0,0,0" Name="MyList" ScrollViewer.VerticalScrollBarVisibility="Disabled" ItemContainerStyle="{StaticResource ListBoxItemStyle1}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Background="Transparent" Margin="10,0,0,0"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Height="55" Margin="20,10,0,0">

How to display a Dictionary in a ListBox

梦想与她 提交于 2019-12-04 17:23:28
I'm trying to display Key/Value Pairs from a Dictionary to a ListBox. Key Value A 10 B 20 C 30 I want to display them in a ListBox in following format A(10) B(20) C(30) Using following code I have been able to link Listbox.Datasource to Dictionary. myListBox.DataSource = new BindingSource(myDictionary, null); Its being displayed as [A, 10] [B, 20] [C, 30] I can't figure out how to format it so that it is displayed in the way I want. Any help will be appreciated. Thanks Ashish Use the Format event on the list box: KeyValuePair<string, int> item = (KeyValuePair<string, int>)e.ListItem; e.Value =

Displaying Content only when ListViewItem is Selected

只谈情不闲聊 提交于 2019-12-04 16:44:28
I have a ListBox when one of the ListBoxItems are selected I want to change the visibility of the button "View" and display it. Meaning that the default state is Hidden. Is this possible and if so, do I solve this with a trigger in XAML or in code behind? XAML Piece <ListBox Background="Transparent" ItemContainerStyle="{StaticResource listBoxTemplate}" BorderThickness="0"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Vertical" VerticalAlignment="Center" /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate> <DataTemplate> <Grid Background="Beige" Margin="10

How to Change the SelectedItem Foreground Text of ListBox Item

自古美人都是妖i 提交于 2019-12-04 16:07:21
I have the following ListBox below. I am not sure how to change the Foreground of a selected item's textblock text when an item is selected, and then back to the original foreground color when an item is unselected (most likely occurring when another item in the ListBox is selected afterwards)? <ListBox Name="ListBox" SelectionMode="Single" ItemsSource="{Binding}" Margin="{Binding}" toolkit:TiltEffect.IsTiltEnabled="True" SelectionChanged="ListBox_SelectionChanged" > <ListBox.ItemsPanel> <ItemsPanelTemplate> <toolkit:WrapPanel ItemWidth="159" ItemHeight="Auto" /> </ItemsPanelTemplate> <

Getting all the items from the listbox winform

喜欢而已 提交于 2019-12-04 15:44:25
Good day! I am having troubles on getting all the items, selected or not, from the listbox. Whenever I click the send button, the only items that I could get is the ones I selected (This is the current results of my code below: http://imgur.com/jA94Bjm ). What I want is to get all the items from the textbox not just from the selected ones and which is not repeating. private void cmd_send_Click_1(object sender, EventArgs e) { for (int i = 0; i < listBox1.Items.Count; i++) { try { String pno = textBox4.Text.ToString(); String path = textBox5.Text.ToString(); String name = textBox6.Text.ToString(

How to get item list from wxpython ListBox

*爱你&永不变心* 提交于 2019-12-04 14:57:07
Is there a single method that returns the list of items contained in a wxPython listBox? I cant seem to find anything anywhere in the documentation or anywhere for that matter. All that I can think to do is to set the selection to all of the items and then get the selected items, though seems like an ugly roundabout way of doing something that should be simple. Update: As pointed out by jeremy the way to do this is with GetStrings() e.g. listBoxList = yourListBox.GetStrings() wx.ListBox is derived from wx.ControlWithitems . I think GetStrings() is what you need. You can get a list of the

How Can I Get the Index of An Item in a ListBox?

冷暖自知 提交于 2019-12-04 14:38:27
I am adding items to a ListBox like so: myListBox.Items.addRange(myObjectArray); and I also want to select some of the items I add by the following: foreach(MyObject m in otherListOfMyObjects) { int index = myListBox.Items.IndexOf(m); myListBox.SelectedIndices.Add(index); } however index is always -1 . Is there a different way to get the index of an object in a ListBox ? You should make sure that MyObject overrides Equals() , GetHashCode() and ToString() so that the IndexOf() method can find the object properly. Technically, ToString() doesn't need to be overridden for equality testing, but it

PreviewKeyDown for Windows Store App ListBox

独自空忆成欢 提交于 2019-12-04 14:13:57
问题 Is there an equivalent to the PreviewKeyDown for a Windows Store App ? It isn't available. I have exactly the same problem as described here: I have a ListBox with a TextBox above it. I would like to use the arrow keys to navigate from the ListBox to the TextBox. The intention is that if the first item in the ListBox is selected, and the user keys up, the TextBox will get focus. 回答1: Ah, tricky. Handling key events isn't super-obvious. Here's what you want: public MainPage() { this

Saving Listbox Data to XML?

为君一笑 提交于 2019-12-04 13:51:34
问题 I have 2 listboxes, the first listbox stores data pointers for each items Object property (defined by a custom class I have written). Whenever I select an item from this listbox, I populate the second listbox by accessing some of the data stored on the first listbox. That is all good, but now I need to know how to save and restore the listboxes to XML. I would appreciate it if someone could provide an example or assist me in writing the code to do this. Here is some sample code to show how I