listbox

Search a ListBox and Select result in C#

两盒软妹~` 提交于 2020-01-03 01:59:54
问题 I have searched the site but could not find a answer. I have a listbox called "CompetitorDetailsOutput" I then have a textbox above called "searchbox" and a button called "searchbutton" The data in the list box constanly changes and get it data from a .txt file wich stores the data in the following format string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12}", Name, CPSA, PostCode, Rank, Score1, Score2, Score3, Score4, Score5, Score6, Score7, Score8, TotalSingleScore); the

WPF ListBox Databinding & Events

喜夏-厌秋 提交于 2020-01-02 23:37:09
问题 My problem is rather simple. I have a ListBox, containing Thumnails (Image) <ListBox Name="ListBox_Thumbnails" ItemsSource="{Binding}" DataContext="{Binding Source= {StaticResource ThumbnailListSource}}" Width="120" HorizontalAlignment="Left" Margin="-1,26,0,54"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <Image Source="{Binding Path=absolutePath}" MouseLeftButtonDown=<!--?????-->/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> I wanted to show an image, but as a new

Get ListBox SelectedItems

久未见 提交于 2020-01-02 17:54:13
问题 I feel like this should be a simple feature but I don't know how to bind to the selected items in a Listbox without using code behind. I have a Listbox with Datatemplate containing a Checkbox. I want to get the list of the checked/selected items. How do I do this? If I cannot get the SelectedItems, I want to bind to something that triggers "SelectedProduct" every time something gets selected so I can iterate through the "ProductList" and find the checked items. However, SelectedItem does not

WPF Relative source- Cannot find source for binding with reference

白昼怎懂夜的黑 提交于 2020-01-02 08:44:23
问题 have you ever have a problem like this: System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.UserControl', AncestorLevel='1''. BindingExpression:Path=DataContext; DataItem=null; target element is 'ContextMenu' (Name=''); target property is 'DataContext' (type 'Object') Code: <ContextMenu DataContext="{Binding Path=DataContext, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type

WPF listbox : problem with selection

与世无争的帅哥 提交于 2020-01-02 08:34:54
问题 In my XAML file, I have a ListBox declared like this : <ListBox x:Name="lstDeck" Height="280" ItemsSource="{Binding Path=Deck}" > <ListBox.ItemTemplate> <DataTemplate> <ListBoxItem Content="{Binding}" /> </DataTemplate> </ListBox.ItemTemplate> </ListBox> In my view model, Deck is an ObservableCollection, so that binding directly displays the content of my collection. But when I have several value that hold the same value (for example "10" six times), the selection in the ListBox has a weird

WPF: Groupstyle not working correctly because of Style and/or modified ListBox

淺唱寂寞╮ 提交于 2020-01-02 07:58:10
问题 I am trying to use a GroupStyle but instead of showing the groupname as a header over the items in the list it only shows the header and not the items. It works fine until I applied a special style to the list. I then decided this style was pretty bogus so I created a UserControl fro this effect. The problem persists. The purpose of the UserControl is to have a expending effect on the selected item where normally it could show some info and then more info when expanded. UserControl:

WPF Listbox separator is shown with different thickness

旧城冷巷雨未停 提交于 2020-01-02 07:30:12
问题 I have created a custom ListBox with each item separated by separator. But I am seeing weird issue. The thickness of separator is not constant across List items. It changes if I change the position of list box as shown in this List Box Image. Below is the source code of custom listbox. <Window x:Class="CustListBox.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:CustListBox" Title=

How can I trap the keyup event on the first item in a ListBox?

倖福魔咒の 提交于 2020-01-02 07:09:15
问题 I have a ListBox with a TextBox above it. I would like to use the arrow keys to navigate from the ListBox to the TextBox. The intention is that if the first item in the ListBox is selected, and the user keys up, the TextBox will get focus. I nearly have this working, but the problem is that when the user keys up, the SelectedItem is changed before the KeyUp event is raised. This means that the navigation to the TextBox happens when the user has selected the second item in the ListBox. How can

How to change ForeColor of SelectedItem in ListBox

时光毁灭记忆、已成空白 提交于 2020-01-02 07:04:44
问题 I am facing a little issue in my project how can I change fore-color of text of selected items in ListBox . I can select all items of ListBox but I don't know how to change fore-color of text of selected items. This code am using in my project for select listbox items for (int i = 0; i < lbProductsToBuy.Items.Count; i++) { lbProductsToBuy.SetSelected(i,true); } printreceiptToken1(); dataGridView67.Rows.Clear(); Thanks. In these images you can see UI of my application. image1 and image2. See

How to change ForeColor of SelectedItem in ListBox

99封情书 提交于 2020-01-02 07:04:07
问题 I am facing a little issue in my project how can I change fore-color of text of selected items in ListBox . I can select all items of ListBox but I don't know how to change fore-color of text of selected items. This code am using in my project for select listbox items for (int i = 0; i < lbProductsToBuy.Items.Count; i++) { lbProductsToBuy.SetSelected(i,true); } printreceiptToken1(); dataGridView67.Rows.Clear(); Thanks. In these images you can see UI of my application. image1 and image2. See