listbox

Add a Load More Button at the end of ListBox without losing Virtualization?

僤鯓⒐⒋嵵緔 提交于 2019-12-18 06:55:00
问题 I know by editing the ListBox 's default style like this, I can have a Button at the very end of the ListBox . <ScrollViewer x:Name="ScrollViewer" ...> <StackPanel> <ItemsPresenter /> <Button /> </StackPanel> </ScrollViewer> However, doing this will break the ListBox 's Virtualization and the rendering time becomes really long. All I can think of is, Create a dummy item and add it to the end of my item collection in the viewmodel, and have a Visibility property in the dummy object called

How To Disable Selected Item In List Box

走远了吗. 提交于 2019-12-18 06:16:06
问题 I have a ListBox in my WinForms application and I want to disable some items on that list, for example if I right click on an item , it gets disabled and if I left click on a disabled item it should be enabled. How can I do this? Thanks very much 回答1: I found a way. We must create a custom ListBox Control to do this. :) With it, you can enable or disable items with item index. using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Drawing;

Xamly determine if a ListBox.Items.Count > 0

前提是你 提交于 2019-12-18 05:27:09
问题 Is there a way in XAML to determine if the ListBox has data? I wanna set its IsVisibile property to false if no data. 回答1: The ListBox contains a HasItems property you can bind to. So you can just do this: <BooleanToVisibilityConverter x:Key="BooleanToVisibility" /> ... <ListBox Visibility="{Binding HasItems, RelativeSource={RelativeSource Self}, Converter=BooleanToVisibility}" /> Or as a Trigger so you don't need the converter: <ListBox> <ListBox.Style> <Style TargetType="{x:Type ListBox}">

SelectedItem set to first item with CollectionViewSource

試著忘記壹切 提交于 2019-12-18 05:03:57
问题 I have a view databound through mvvm light to a viewmodel in my WP7 project. The view contains a Listbox with following settings: <ListBox x:Name="StationList" ItemsSource="{Binding StationList}" SelectedItem="{Binding SelectedStation, Mode=TwoWay}" > The StationList is a ObservableCollection. Now when the view gets loaded, everything looks great! The list is shown and NO item is selected! But when I change the XAML to: <ListBox x:Name="StationList" ItemsSource="{Binding Source=

Way to color parts of the Listbox/ListView line in C# WinForms?

大城市里の小女人 提交于 2019-12-18 04:47:13
问题 Is there a way to color parts of ListBox Items (not only whole line)? For example listbox item consists of 5 words and only one is colored or 3 of 5. Is there a way to do the same with ListView? (I know that ListView can be colored per column but i would like to have multiple colors in one column). I am interested in only free solutions, and preferred that they are not heavy to implement or change current usage (the least effort to introduce colored ListBox in place of normal one the better).

Setting focus on a ListBox item breaks keyboard navigation

强颜欢笑 提交于 2019-12-18 04:45:15
问题 After selecting ListBox item programmatically it is needed to press down\up key two times to move the selection. Any suggestions? View: <ListBox Name="lbActions" Canvas.Left="10" Canvas.Top="10" Width="260" Height="180"> <ListBoxItem Name="Open" IsSelected="true" Content="Open"></ListBoxItem> <ListBoxItem Name="Enter" Content="Enter"></ListBoxItem> <ListBoxItem Name="Print" Content="Print"></ListBoxItem> </ListBox> Code: public View() { lbActions.Focus(); lbActions.SelectedIndex = 0; //not

How to list text files in the selected directory in a listbox?

烈酒焚心 提交于 2019-12-18 04:41:41
问题 How can I list the text files in a certain directory (C:\Users\Ece\Documents\Testings) in a listbox of a WinForm(Windows application)? 回答1: // What directory are the files in?... DirectoryInfo dinfo = new DirectoryInfo(@"C:\TestDirectory"); // What type of file do we want?... FileInfo[] Files = dinfo.GetFiles("*.txt"); // Iterate through each file, displaying only the name inside the listbox... foreach( FileInfo file in Files ) { listbox1.Items.Add(file.Name); } // A statement, followed by a

ASP:ListBox Get Selected Items - One Liner?

落爺英雄遲暮 提交于 2019-12-18 04:04:09
问题 I am trying to get the selected items of an asp:ListBox control and put them in a comma delimited string. There has got to be a simpler way of doing this then: foreach (ListItem listItem in lbAppGroup.Items) { if (listItem.Selected == true) { Trace.Warn("Selected Item", listItem.Value); } } Is there a way to get this into one line? like my pseudo code here: string values = myListBox.SelectedItems; I am using ASP.NET and C# 3.5. Thanks for any help!! 回答1: Using LINQ: string values = String

WPF drag and drop from a ListBox that has SelectionMode=Extended

爱⌒轻易说出口 提交于 2019-12-18 03:42:31
问题 I have a ListBox and want the selection-mode to be extended. Also I want have to implement drag and drop functionality. The problem now is, that if the mouse is clicked on a selected item, it will be immediately be selected as single selection instead of waiting to the mouse-up-event for doing this. Due to this behaviour, start dragging multiple items is for the user quasi impossible because always he clicks on the selection to start dragging, the selection changes to the item that is under

C# : change listbox items color

試著忘記壹切 提交于 2019-12-18 02:27:31
问题 i am working on program on windows forms I have a listbox and I am validating data I want the correct data be added to the listbox with color green while the invalid data added with red color and I also want from the listbox to auto scroll down when an item is added and thanks code : try { validatedata; listBox1.Items.Add("Successfully validated the data : "+validateddata); } catch() { listBox1.Items.Add("Failed to validate data: " +validateddata); } 回答1: Assuming WinForms, this is what I