listbox

Changing (Enable/Disable) GroupStyle in ListView for different category items

老子叫甜甜 提交于 2019-12-23 22:16:50
问题 How can I switch between GroupStyles for a ListView based on some conditions at run time? For instance I need to use Default for items that that have GroupStyle Header name null, and if it is not null then use the custom GroupStyle theme? I tried GroupStyleSelector , and it doesn't work, because it works for multi level grouping, and in my case I have only one level grouping. If yes, then how? Custom GroupStyle : <Style x:Key="grouping" TargetType="{x:Type GroupStyle}"> <Setter Property=

How to group items in a list by their first letter in Silverlight?

被刻印的时光 ゝ 提交于 2019-12-23 22:09:33
问题 I have a ListBox to which I bound a sorted list of strings. I would like to display the list with dividers (headers) that announce the new letter - something like the 'Contacts' list on the iPhone. Does anybody know how to achieve this goal? Perhaps using ListBox is not the right idea. I am doing this with VS Express 2010 for Windows Phone 7. 回答1: I can't speak for silverlight, but the general .NET Practice would be as follows: var groupings = mySortedString.GroupBy(x => x.Substring(0,1));

Setting properties of auto-generated listboxitem

戏子无情 提交于 2019-12-23 21:20:26
问题 I am trying to set the inputbindings of the auto-generated ListBoxItems of a databound ListBox. The code below does not work. The compiler complains that "The Property Setter 'InputBindings' cannot be set because it does not have an accessible set accessor." What is the correct syntax to set the InputBindings? <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="ListBoxItem.InputBindings"> <Setter.Value> <MouseBinding Command="{Binding OpenCommand}" Gesture

How to clear an ASP.NET listbox with Javascript?

这一生的挚爱 提交于 2019-12-23 20:26:59
问题 I'm trying to clear all of the items in an ASP.NET listbox via javascript, but sadly document.getElementById("<%= lstNames.clientID %>").items.clear; does not work. Any ideas would be greatly appreciated! Thanks, Jason 回答1: Use jquery document.getElementById("<%= lstNames.clientID %>").empty() or document.getElementById("<%= lstNames.clientID %>").options.length = 0; 回答2: Use: document.getElementById("<%= lstNames.clientID %>").selectedIndex = -1; // will throw error on next if there are

windows phone 7 TextBlock TextWrapping not honored in listbox

你离开我真会死。 提交于 2019-12-23 19:56:48
问题 I have a listbox defined as : <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <ListBox x:Name="myListBox" Width="468" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <toolkit:WrapPanel /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.Template> <ControlTemplate> <ScrollViewer Width="468"> <ItemsPresenter /> </ScrollViewer> </ControlTemplate> </ListBox.Template> </ListBox> </Grid> In the code, I create multiple textBlocks as

Operation not supported on read-only collection

痴心易碎 提交于 2019-12-23 18:32:25
问题 I have a ListBox with rows where each row consist of an "Image" and a "TextBlock". When I delete one row in the back with code like: this.UserListBox.Items.RemoveAt(this.UserListBox.SelectedIndex); There it throws an exception: Operation not supported on read-only collection. How can I delete row from the listbox? I am writing a Windows phone 7 APP. 回答1: If you set ItemsSource on the ListBox, then Items is internally generated and readonly. In such case you need to delete the item from the

How do I get the selected items from a multi-select listbox in order that they were selected?

怎甘沉沦 提交于 2019-12-23 17:30:25
问题 I have web application in which i populate listbox using items from database on page load. I get the all items from listbox that are selected but they are in order in which they populated. I want these items to be in the order that they are selected by user. I tried .change(function() using jQuery but it returns only first selected items value. I attaching my code for reference. I have used listbox using http://harvesthq.github.com/chosen/ This is my listbox: <asp:ListBox ID="dr_menuitem"

WPF ListBox ListBoxItem Binding

我只是一个虾纸丫 提交于 2019-12-23 13:09:27
问题 I am going through the Sams book "Teach Yourself WPF in 24 Hours". At one point the authors show how you can bind a ListBox's selected-item value to a property. I get that, it's pretty straightforward. But when I try to create my own ListBox control with my own ListBoxItems, I can't seem to get it to work. The ListBox that works uses a system collection as its ItemsSource property: <ListBox x:Name="FontList" DockPanel.Dock="Left" ItemsSource="{x:Static Fonts.SystemFontFamilies}" Width="160" /

Overriding DrawItem for ListBox - unselected items are not redrawn

删除回忆录丶 提交于 2019-12-23 12:59:51
问题 This is a C# desktop application. The DrawStyle property of my ListBox is set to OwnerDrawFixed . The problem: I override DrawItem to draw text in different fonts, and it works. But when I start resizing the form at the runtime, the selected item is drawn correctly, but the rest of them are not redrawn, causing text looking corrupt for unselected items. Here's my code: private void listDevices_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); string textDevice = ((ListBox

Search listbox for item containing a string

冷暖自知 提交于 2019-12-23 12:42:52
问题 Background : I am building a database application to store information about my massive movie collection. The listbox contains hundreds of items so I decided to implement a search feature which would highlight all items that contain a particular string. Sometimes it's hard to remember an entire movie title so I thought this would come in handy. I found this useful code on the Microsoft site that highlights all items in a listbox that contain a particular string. How can I modify it to search