listbox

Tkinter Listbox

核能气质少年 提交于 2020-01-01 11:22:47
问题 I want to execute function with one click on listbox. This is my idea: from Tkinter import * import Tkinter def immediately(): print Lb1.curselection() top = Tk() Lb1 = Listbox(top) Lb1.insert(1, "Python") Lb1.insert(2, "Perl") Lb1.insert(3, "C") Lb1.insert(4, "PHP") Lb1.insert(5, "JSP") Lb1.insert(6, "Ruby") Lb1.pack() Lb1.bind('<Button-1>', lambda event :immediately() ) top.mainloop() But this function print before execute selecting...You will see what is the problrm when you run this code.

Tkinter Listbox

一曲冷凌霜 提交于 2020-01-01 11:22:18
问题 I want to execute function with one click on listbox. This is my idea: from Tkinter import * import Tkinter def immediately(): print Lb1.curselection() top = Tk() Lb1 = Listbox(top) Lb1.insert(1, "Python") Lb1.insert(2, "Perl") Lb1.insert(3, "C") Lb1.insert(4, "PHP") Lb1.insert(5, "JSP") Lb1.insert(6, "Ruby") Lb1.pack() Lb1.bind('<Button-1>', lambda event :immediately() ) top.mainloop() But this function print before execute selecting...You will see what is the problrm when you run this code.

ListBox margin is not the same in Windows 7 and Windows 8

二次信任 提交于 2020-01-01 08:41:55
问题 I have styled an WPF ListBox. I'm developing under Windows 8. After setup the style to be as follows (see image), when I test the application in Windows 7, the margin is not the same. As you can see in the imagen the separation between nodes is 1px in Windows 8, but 0 px in Windows 7. Do you know why is this, and how to solve it? Thanks in advance. 回答1: I actually managed to get rid of it myself, it looks like it's ListViewItem style that's being changed by Windows8, adding a style to the

Moving ListBoxItem Up/Down in WPF

天涯浪子 提交于 2020-01-01 07:07:06
问题 I've created a listbox which contain filenames. I want to give user a option to move up and down file name using up/down button and using drag and drop. Anyone has an idea how to achieve this functionality. XAML Code: <ListBox Grid.Column="0" Name="listBox1" AllowDrop="True" Drop="listBox1_Drop" /> <StackPanel Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center"> <Button Name="moveUp" Content="Ç" FontFamily="Wingdings 3" Margin="3,3,3,3" Click="moveUp_Click" /> <Button

ListBox Style Selected item on windows phone

我与影子孤独终老i 提交于 2020-01-01 04:31:46
问题 i would like know how can i add a style when a item of the listbox is selected. I have the following listbox: <ListBox x:Name="ListBoxDays" VerticalAlignment="Top" ItemTemplate="{StaticResource WeekDayTemplate}" ItemsSource="{Binding WeekDayList}" /> And i also have a DataTemplate to the listbox. <phone:PhoneApplicationPage.Resources> <DataTemplate x:Key="WeekDayTemplate"> <StackPanel x:Name="stackPanel" Orientation="Horizontal" Width="400" Margin="12,0,0,10" Height="100" > <StackPanel

WPF Listbox with touch inertia pulls down entire window

别等时光非礼了梦想. 提交于 2020-01-01 04:04:27
问题 I have a full screen WPF application built for a touch monitor, and I have some Listbox s on the main screen. When I flick the 'Listbox' it scrolls fine, but when it gets to the end of the list, the entire application gets pulled down from the top of the screen, can I stop this behavior somehow? Has anyone else seen this? 回答1: Yes, that default behaviour of the ListBox (or rather, the ScrollViewer inside the default ListBox template) is weird - when I first came across it, I thought it must

Autoscrolling a Listbox under a certain situation

风流意气都作罢 提交于 2020-01-01 02:45:08
问题 How to autoscroll a Listbox after adding a new item, but only if the scrollbar is at the bottom before the item is added? 回答1: You can just try it : listBox1.SelectedIndex = listBox1.Items.Count - 1; listBox1.SelectedIndex = -1; 回答2: This sample code should help you out. I've done this many times with a TextBox but it took awhile to figure it out for a ListBox Obviously, it's just a Form with a Button and a ListBox. Modify to fit your needs: private void button1_Click(object sender, EventArgs

WPF listbox copy to clipboard

折月煮酒 提交于 2019-12-31 12:54:42
问题 I am trying to copy a standard WPF listbox selected Item (displayed) text to clipboard on CTRL+C. Is there any simple way to achieve this. If it is something that works for all the listboxes int he app.. that would be great. Thanks in advance. 回答1: As you're in WPF so you could try the attached behaviours First you need a class like this: public static class ListBoxBehaviour { public static readonly DependencyProperty AutoCopyProperty = DependencyProperty.RegisterAttached("AutoCopy", typeof

ListBox templating: how to create a common template but still change content based on item

假装没事ソ 提交于 2019-12-31 07:01:14
问题 I've been templating ListBoxes for sometime in WPF, but I was wondering if there was a way to have a template for the ListBoxItem that would apply to all the items in the ListBox, but also have a ItemTemplateSelector to alter the contents of the containers. I have a list of strings and images and I want to display them uniquely such that the image displays with a frame and strings display in a textbox to be edited. I made an ItemTemplateSelector and select the template based on the type.

File path to file name String converter not working

社会主义新天地 提交于 2019-12-31 05:34:28
问题 Using a wpf ListBox I'm trying to display a list of filename without displaying the full path (more convenient for user). Data comes from an ObservableCollection which is filled using Dialog. private ObservableCollection<string> _VidFileDisplay = new ObservableCollection<string>(new[] {""}); public ObservableCollection<string> VidFileDisplay { get { return _VidFileDisplay; } set { _VidFileDisplay = value; } } In the end I want to select some items and get back the full file path. For this I