listbox

How to highlight matching sub-strings inside a ListBox?

强颜欢笑 提交于 2019-11-30 05:33:48
问题 I have one TextBox and one listbox for searching a collection of data. While searching a text inside a Listbox if that matching string is found anywhere in the list it should show in Green color with Bold. eg. I have string collection like "Dependency Property, Custom Property, Normal Property". If I type in the Search Text box "prop" all the Three with "prop" (only the word Prop) should be in Bold and its color should be in green. Any idea how it can be done?. Data inside listbox is

formcollection only holds the selected html.listbox items values? MVC

这一生的挚爱 提交于 2019-11-30 05:01:54
My scenario is this: I have two listbox's, one that contains all my database items, and an empty one. The user adds the items needed from the full listbox to the empty listbox. I'm using a form to submit all the items the user has added. The problem is, only the selected items from the listbox are submitted. So if the user deselects some of the items, they wont be submitted in the form. My view looks like so: <% using (Html.BeginForm("MyAction", "MyController")) { %> <%= Html.ListBox("AddedItems", Model.Items)%> <input type="submit" value="Submit" name="SubmitButton"/> <% } %> My Controller

Lazy loading of listbox images from isolated storage

旧街凉风 提交于 2019-11-30 05:00:09
问题 I have lots of images stored in isolated storage and want to display them in a listbox. However, I don't want all images to be loaded right away but lazily. So only when the user scrolls to see new items the images should be loaded. I also want to use data binding for providing the list item's data and image. In the tests I did all images always got loaded right away and at once, so I am unsure whether this lazy loading can be achieved with the default ListBox and data binding. Can it? 回答1:

How to move item in listBox up and down?

故事扮演 提交于 2019-11-30 04:24:45
I have a listBox1 object and it contains some items. I have a button to move selected item up and another to move selected item down. What should the code be to the two buttons? private void UpClick() { // only if the first item isn't the current one if(listBox1.ListIndex > 0) { // add a duplicate item up in the listbox listBox1.AddItem(listBox1.Text, listBox1.ListIndex - 1); // make it the current item listBox1.ListIndex = (listBox1.ListIndex - 2); // delete the old occurrence of this item listBox1.RemoveItem(listBox1.ListIndex + 2); } } private void DownClick() { // only if the last item isn

c# wpf - cannot set both DisplayMemberPath and ItemTemplate

天涯浪子 提交于 2019-11-30 04:20:26
问题 I want to add tooltip in listboxItem but it starts problem when there is DisplayMemberPath. Error message said: cannot set both DisplayMemberPath and ItemTemplate. When I removed DisplayMemberPath, tooltip in each list item is working. But i dont want to remove DisplayMemember because i need it. How to solve this problem? <ListBox x:Name="lstToys" Style="{DynamicResource ListBoxStyle1}" ItemsSource="{Binding Strings}" DisplayMemberPath="Toys" MouseDoubleClick="lstToys_MouseDoubleClick">

WPF: Disable ListBox, but enable scrolling

我们两清 提交于 2019-11-30 03:51:47
问题 Been banging my head against this all morning. Basically, I have a listbox, and I want to keep people from changing the selection during a long running process, but allow them to still scroll. Solution: All the answers were good, I went with swallowing mouse events since that was the most straight forward. I wired PreviewMouseDown and PreviewMouseUp to a single event, which checked my backgroundWorker.IsBusy, and if it was set the IsHandled property on the event args to true. 回答1: The trick

ListBoxItem produces “System.Windows.Data Error: 4” binding error

久未见 提交于 2019-11-30 02:56:09
I have created 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.Triggers> <!--This trigger is needed, because RelativeSource binding can only succeeds if the current ListBoxItem is already connected to its visual parent--> <Trigger Property="IsVisible" Value="True"> <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment,

C#: easiest way to populate a ListBox from a List

白昼怎懂夜的黑 提交于 2019-11-30 01:26:54
If I have a list of strings, eg: List<string> MyList = new List<string>(); MyList.Add("HELLO"); MyList.Add("WORLD"); Is there an easy way to populate a ListBox using the contents of MyList? Adriaan Stander Try : List<string> MyList = new List<string>(); MyList.Add("HELLO"); MyList.Add("WORLD"); listBox1.DataSource = MyList; Have a look at ListControl.DataSource Property You can also use the AddRange method listBox1.Items.AddRange(myList.ToArray()); Is this what you are looking for: myListBox.DataSource = MyList; This also could be easiest way to add items in ListBox. for (int i = 0; i < MyList

WPF ListBox Scroll to end automatically

≯℡__Kan透↙ 提交于 2019-11-30 01:20:17
In my application, I have a ListBox with items. The application is written in WPF. How can I scroll automatically to the last added item? I want the ScrollViewer to be moved to the end of the list when new item has been added. Is there any event like ItemsChanged ? (I don't want to use the SelectionChanged event) Oz Mayt Try this: lstBox.SelectedIndex = lstBox.Items.Count -1; lstBox.ScrollIntoView(lstBox.SelectedItem) ; In your MainWindow, this will select and focus on last item on the list! The easiest way to do this: if (VisualTreeHelper.GetChildrenCount(listView) > 0) { Border border =

ListBox Slide Animation On New Item Added

馋奶兔 提交于 2019-11-30 00:38:22
I am working on a news feed. This will update every so often and if new items are found, I want to slide in the new content from the top. Right now, I am just having it fade in by doing the following: <ListBox Grid.Row="0" Height="Auto" HorizontalAlignment="Stretch" Margin="5,5,5,5" VerticalAlignment="Top" ItemsSource="{Binding NewsItems,UpdateSourceTrigger=PropertyChanged}" > <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Style.Triggers> <EventTrigger RoutedEvent="Loaded"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty