listbox

WPF ListBox - how to put values from dataTable?

故事扮演 提交于 2019-12-05 18:40:10
I have ListBox and want to put values in this listbox from a DataTable : listBoxVisibleFields.DataContext = SelectedFields; Where SelectedFields is a DataTable filled with data. But this code does not work. My ListBox is empty. As I remember, in WinForms was sucha a thing for list box like ValueMember and DisplayMember , but in WPF I dont find something like that... Does someone know how to fill simply my ListBox from DataTable ? The property you are looking for is ItemsSource instead of DataContext . The property most closely resembling ValueMember is called SelectedValuePath (see this

WPF ListBox with self-removing items

守給你的承諾、 提交于 2019-12-05 18:37:48
I am trying to set up a listbox where users can remove items by clicking on each value they want to remove. I set up the style for my listbox (DisplayName is a member of the item class) in orderto include a button for each item: <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding DisplayName}" /> <Button Content="[x]" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> Now I am having trouble trying to set the button to delete the associated entry. Can anybody point a way? Thank you in advance. TMan I'd recommend you use an ICommand and

After rebinding Silverlight Listbox control how do you get it listbox to scroll to back to the top?

半城伤御伤魂 提交于 2019-12-05 18:25:22
I have a silverlight listbox that is being used as a search result box. I'm using dynamic searching (keyups in the search box cause the events to fire to filter this list box's contents). The issue I'm running into is if the user scrolls down when the box is unfiltered, then does the search, the rebinding of the listbox does not cause the scroll to go back up to the top making the results look like there is only one value in it. the code I have so far for the listbox is this (This is a simplified version): XAML: <Grid x:Name="MainGrid" Rows="2"> <StackPanel Orientation="Horizontal" Grid.Row="0

WPF: How to programmatically give visual feedback that the keyboard focus is in a listbox?

Deadly 提交于 2019-12-05 18:22:40
I am writing an application with a listbox allowing multi-selection (SelectionMode=Multiple); the items in the lisbox are ingredients for a recipe. Unfortunately, clicking on a listbox item selects this item, which may not be desired. I would like the following scenario: the user clicks on the listbox in order to select the listbox (the listbox itself, not an item) the user scrolls to the right item and selects it What I did is style the ListBoxItem to include a checkbox and a ContentPresenter (like in this blog ). Still, clicking on the ingredient name selects it. So, I trap the MouseDown

Listbox manual DrawItem big font size

你。 提交于 2019-12-05 18:15:34
问题 I'm trying to draw items that end of them is an * character in red (and remove that * character) and draw other items in black color. this is my code: private void listBox1_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground() ; //Draw our regular background if (Microsoft.VisualBasic.Strings.Right(listBox1.Items[e.Index].ToString(), 1) == "*") { e.Graphics.DrawString(Microsoft.VisualBasic.Strings.Mid(listBox1.Items[e.Index].ToString(),1,listBox1.Items[e.Index].ToString().Length -

Getting Selected Items From WinForm ListBox?

纵然是瞬间 提交于 2019-12-05 17:53:14
I have a ListBox in a WinForm with multiselect enabled. The selected items appear to be stored in an object, how to I get their values? Easy, depending on what type you stored: foreach (MyItemType item in listBox1.SelectedItems) { ... } Because this is an older, non-generic collection it is better not to use var to declare the item variable. That would only get you a reference of type object . You can also use other properties like: if (listBox1.SelectedItems.Count > 0) ... Just use the following code to display the selected item from the listbox - for WinForm app... string s = listbox1.Text;

Windows Phone: how to disable touch scrolling in ScrollViewer (Listbox)?

久未见 提交于 2019-12-05 17:45:58
i have a scrollviewer with a listbox inside: i need to disable the vertical scroll by touch, how can i? In other words, the user can't scroll with the touch (i have put buttons, but this is another story). <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled" x:Name="imagesScrollview" Width="480" Height="595" Margin="0,112,0,63"> <ScrollViewer.RenderTransform> <CompositeTransform/> </ScrollViewer.RenderTransform> <ListBox Name="listavideo" Height="595" Width="480"> <ListBox.ItemTemplate> <DataTemplate> <Button Width="470" Height="146" Background="White"

How to add Autoscroll on insert in Tkinter Listbox?

隐身守侯 提交于 2019-12-05 16:42:22
I'm using a listbox (with scrollbar) for logging: self.listbox_log = Tkinter.Listbox(root, height = 5, width = 0,) self.scrollbar_log = Tkinter.Scrollbar(root,) self.listbox_log.configure(yscrollcommand = self.scrollbar_log.set) self.scrollbar_log.configure(command = self.listbox_log.yview) Now, when I do: self.listbox_log.insert(END,str) I want the inserted element to be selected. I've tried: self.listbox_log.selection_anchor(END) but that doesn't work... Please suggest a solution... AFAIK the ScrollBar widget doesn't have an auto-scroll feature, but it can be easily implemented by calling

ZK window not unique in ID space

烂漫一生 提交于 2019-12-05 16:26:55
In our project we use ZK for webpages. There is a combobox which has lists. When selected, it fetches data from a java object through onSelect , i have given the logic. when i select one there are 4 listboxes on that page to be filled with data according to the selection. when i select first time, no problem occurs. But on second time i get an error pop-up like "Not Unique in the id space of Window" and showing the list box item id which have to be filled on select. Can any one help out there? Note: Though it shows this error i get the listboxes filled correctly according to the combo box

How to ensure that no item is selected in databound ListBox?

北战南征 提交于 2019-12-05 16:24:59
OK, this must be a duplicate question, but I cannot find the answer: I have a listbox that is databound to a Collection. By default Items[0] is selected. How can I prevent this in order to ensure that the SelectionChanged event is raised any time I click a ListBoxItem? EDIT: I had already dismissed the SelectedIndex=-1 route, but I tried again: Setting the SelectedIndex to -1 in the Listbox's constructor (or as an attribute in XAML) does not work. It seems that the listbox is populated after the initialization and the selectedindex will become 0 after all.Same story for setting the