listbox

WPF ListBox Highlight in Windows 10

让人想犯罪 __ 提交于 2019-12-18 01:05:16
问题 I'm fairly new to WPF but experienced in .NET (Winforms). I'm trying to manipulate the highlight style of a listbox to control the focused and unfocused color of the selected item. Every single tutorial on this that I have found uses a custom style to assign a new value to the SystemColors.HighlightBrushKey and SystemColors.ControlBrushKey. But it isn't working. After countless hours trying to get this to work, it occurred to me that maybe it was OS related. I had been trying it on a Windows

WPF Listbox auto scroll while dragging

南笙酒味 提交于 2019-12-17 23:17:33
问题 I have a WPF app that has a ListBox . The drag mechanism is already implemented, but when the list is too long and I want to move an item to a position not visible I can't. For example, the screen shows 10 items. And I have 20 items. If I want to drag the last item to the first position I must drag to the top and drop. Scroll up and drag again. How can I make the ListBox auto scroll? 回答1: Got it. Used the event DragOver of the ListBox , used the function found here to get the scrollviewer of

How can I find an item in a WPF ListBox by typing?

让人想犯罪 __ 提交于 2019-12-17 22:54:48
问题 Most list boxes allow you to find items within them by typing the first letters of the displayed text. If the typed letters match multiple items, then you can keep adding letters to narrow the search. I need to do this in a WPF ListBox . However, the items aren't plain strings -- they're custom objects that I present using a DataTemplate . I'm hoping that there's a way I can provide a path to the string value that should be used for this textual keyboard navigation of the ListBox items. How

WPF ListBox Scroll to end automatically

那年仲夏 提交于 2019-12-17 22:39:15
问题 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) 回答1: 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! 回答2

What's the difference between ItemTemplate and ItemContainerStyle in a WPF ListBox?

梦想与她 提交于 2019-12-17 21:57:46
问题 In WPF Listbox , I'm confused with these 2 notions: ItemTemplate and ItemContainerStyle Can someone explain me more? 回答1: The ItemTemplate is for styling how the content of your data item appears. You use it to bind data fields, format display strings, and so forth. It determines how the data is presented. The ItemContainerStyle is for styling the container of the data item. In a list box, this would be a ListBoxItem. Styling here affects things like selection behavior or background color. It

CheckBox inside ListBox

岁酱吖の 提交于 2019-12-17 21:33:07
问题 How to add checkbox inside the listbox. Where ChechBoxList controls is not good for more records, By using listbox user can easily scroll to choose the item. Geetha. 回答1: What you want is the CheckBoxList. Newer CheckBoxList Pretty nice step-by-step here. 回答2: what about checkedListBox ? <asp:CheckBoxList id="checkboxlist1" runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> </asp:CheckBoxList> To access items on user

How can I assign the value selected in a listbox to an enum var?

你说的曾经没有我的故事 提交于 2019-12-17 21:23:54
问题 I want to avoid the kludginess of: private void listBoxBeltPrinters_SelectedIndexChanged(object sender, System.EventArgs e) { string sel = string listBoxBeltPrinters.SelectedItem.ToString(); if (sel == "Zebra QL220") { PrintUtils.printerChoice = PrintUtils.BeltPrinterType.ZebraQL220; } else if (sel == "ONiel") { PrintUtils.printerChoice = PrintUtils.BeltPrinterType.ONiel; } else if ( . . .) } Is there a way I can more elegantly or eloquently assign to an enum based on a list box selection,

Color a WPF ListBox item based on a property

谁说我不能喝 提交于 2019-12-17 21:14:38
问题 I have an observable collection of Song objects. These song objects have a property called "Playing" that is a bool (bad naming, I know). The songs display in a ListBox in my application. I want the song that is Playing to be colored red. I have been working with triggers all day trying to make this work. So far, I have gotten to the point where they are colored based on what Playing is set to when the song is added to the list. Is it possible to make it change when the Playing property

ListBox data virtualization is not taking effect

假装没事ソ 提交于 2019-12-17 19:54:09
问题 I had 1000 items from xml and loaded them in a List object. List is databound to ListBox which is horizontally oriented so user can flip through items left to right or right to left. Since number of items are huge my app was quitting probably due to excessive memory usage. If I reduced the items to 50 it worked. I found this article http://shawnoster.com/blog/post/Improving-ListBox-Performance-in-Silverlight-for-Windows-Phone-7-Data-Virtualization.aspx and then this article on data

MoveFocus from one listBox to another

☆樱花仙子☆ 提交于 2019-12-17 19:54:08
问题 I have the Output something like Windows 8 Start Menu. Here is screen-shot of my Output: I have successfully got that output by getting help from this question. XAML for achieving the below output: <ItemsControl ItemsSource="{Binding MenuCategories}" > <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel IsItemsHost="True" Orientation="Horizontal" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <Grid > <Grid.RowDefinitions> <RowDefinition