listbox

Overriding SystemColors in local Resources dictionary

半世苍凉 提交于 2019-12-22 01:36:19
问题 I'm trying to hide the visual hints that indicate selection in a WPF ListBox . This answer suggests this should work by overriding the SystemColors for that ListBox . I created a new WPF project and edited the MainWindow.xaml like this: <Window x:Class="WpfListboxWithoutSelection.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http:/

Calculating number of visible items in ListBox

自古美人都是妖i 提交于 2019-12-21 22:10:06
问题 I have a class called Book; class Book { public string Name { get; set; } public string Author { get; set; } public int PagesCount { get; set; } public int Category { get; set; } } The ListBox displays a list of Books and the ItemTemplate has been modified so as to visually represent the Book. The text shows the book's Name, author and the number of pages. The category, however is represented by a certain color (for example, history is blue, romance is red etc.) Now, the text has an

How to display a Dictionary in a ListBox

拜拜、爱过 提交于 2019-12-21 22:06:58
问题 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 回答1: Use the

can't clear WPF ListBox.SelectedItems collection

血红的双手。 提交于 2019-12-21 19:59:27
问题 I can't seem to get the SelectedItems collection of a data bound WPF ListBox to clear. I've tried calling ListBox.SelectedItems.Clear(), i've tried setting the SelectedIndex to -1, setting the SelectedItem to null and calling ListBox.UnselectAll(). While debugging it appears that either the assignments don't take or something is resetting the SelectedItems collection, but I'm not sure what. I put a breakpoint in the SelectionChanged callback and it never gets hit unexpectedly yet the

VBA Excel Populate ListBox with multiple columns

若如初见. 提交于 2019-12-21 19:43:43
问题 This may be a cheap question for some but I'm totally confused on how to populate my listbox. Using this line I can populate the listbox as shown below: ListBox1.List = Sheets("Sheet1").Cells(1, 1).CurrentRegion.Value or Dim rngName As Range Dim ws As Worksheet Dim i As Integer Set ws = Worksheets("Sheet1") For i = 1 To ws.Cells(ws.Rows.Count, 1).End(xlUp).Row Step 1 If ws.Cells(i, 1).Value <> vbNullString Then Me.ListBox1.AddItem ws.Cells(i, 1).Value Next i Below is the data I'm planning to

WP7 TextBlock inside a ListBox not wrapping text

泪湿孤枕 提交于 2019-12-21 16:56:14
问题 I have a ListBox which has StackPanel s holding a TextBlock and an Image horizontally, followed by a ContentPresenter . This is what the XAML looks like: <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <ListBox x:Name="MainListBox" Margin="12,0,12,0" SelectionChanged="MainListBox_SelectionChanged"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <toolkit:ContextMenuService.ContextMenu> <toolkit:ContextMenu x:Name="ContextMenu" Opened="ContextMenu_Opened"> <toolkit:MenuItem

WPF Bind List to Multi-Column ListBox

末鹿安然 提交于 2019-12-21 06:28:23
问题 Since starting in WPF I am still struggling to understand the data binding functionality. I am trying to use a multi column list box and my XAMl looks like this: <ListBox Name="RecordList"> <ListView Name="RecordListView"> <ListView.View> <GridView> <GridView.Columns> <GridViewColumn Header="1" Width="Auto" DisplayMemberBinding="{Binding Path=Field1}" /> <GridViewColumn Header="2" Width="50" DisplayMemberBinding="{Binding Path=Field2}" /> <GridViewColumn Header="3" Width="100"

C# Searching a listBox

半腔热情 提交于 2019-12-21 05:41:27
问题 I have a large amount of items in a listBox called listBox1. I also have a textBox (textBox1) at the top. I want to be able to type into the textBox and the listBox searches through it's item's and finds ones that contain what I am typing. For example, say the listBox contains "Cat" "Dog" "Carrot" and "Brocolli" If I start typing the letter C, then I want it to show both Cat and Carrot, when I type a it should keep showing them both, but when I add an r it should remove Cat from the list. Is

C# Searching a listBox

十年热恋 提交于 2019-12-21 05:41:07
问题 I have a large amount of items in a listBox called listBox1. I also have a textBox (textBox1) at the top. I want to be able to type into the textBox and the listBox searches through it's item's and finds ones that contain what I am typing. For example, say the listBox contains "Cat" "Dog" "Carrot" and "Brocolli" If I start typing the letter C, then I want it to show both Cat and Carrot, when I type a it should keep showing them both, but when I add an r it should remove Cat from the list. Is

Using ItemsSource to populate WPF ListBox - Good Idea?

余生颓废 提交于 2019-12-21 05:01:17
问题 I'm a (relatively) experienced Cocoa/Objective-C coder, and am teaching myself C# and the WPF framework. In Cocoa, when populating an NSTableView , it's relatively simply to assign a delegate and datasource to the view. Those delegate/datasource methods are then used to populate the table, and to determine its behavior. I'm putting together a simple application that has a list of objects, lets call them Dog objects, that each have a public string name . This is the return value of Dog