listbox

ListBox ItemContainerGenerator returns null even when listbox has items

折月煮酒 提交于 2020-01-02 05:58:13
问题 I've a listbox with couple of items, till the time no scrollbar appears everything goes perfectly fine but once scrollbar comes then ItemContainerGenerator returns null. I read some blogs and found it may be because of vertualization stackpanel. If i disable that then it may work but in my case it would make listbox too much heavy and less efficient. Here is the code for listbox: <ListBox x:Name="EventListBox" DockPanel.Dock="Top" Margin="5,5,5,5" FocusVisualStyle="{x:Null}" ItemsSource="

ListBoxItem style in <ListBox.Resources> or in <ListBox.ItemContainerStyle>?

倖福魔咒の 提交于 2020-01-02 04:47:07
问题 I can put a xaml Style for ListBoxItem in <ListBox.Resources> or in <ListBox.ItemContainerStyle> . See code. Question is: what is the difference, what should I prefer? <ListBox.Resources> <Style TargetType="ListBoxItem"> <Setter Property="Canvas.Top" Value="{Binding Top}"/> <Setter Property="Canvas.Left" Value="{Binding Left}"/> <Setter Property="VerticalContentAlignment" Value="Stretch"/> <Setter Property="HorizontalContentAlignment" Value="Stretch"/> <Setter Property="Padding" Value="0"/> <

How to make Listbox's texts center aligned in desktop application using c#.net

半世苍凉 提交于 2020-01-02 03:23:50
问题 Please tell me how can I align center to my ListBox's text in desktop application. I am using C#.Net in Visual Studio 2005. I am using Windows forms. 回答1: You can set the DrawMode property of the ListBox to DrawMode.OwnerDrawFixed , which gives you control over the entire graphical representation of each item. For instance: ListBox listBox = new ListBox(); listBox.DrawMode = DrawMode.OwnerDrawFixed; listBox.DrawItem += new DrawItemEventHandler(listBox_DrawItem); void listBox_DrawItem(object

WPF: Sort a list box

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 18:30:28
问题 How do I sort a ListBox by two fields? (In this case the ApplicationName and InstanceName properties of my model class.) 回答1: It depends on your data source. Here are a couple of ways.... using linq on lisbox data source from 101 LINQ Samples: string[] digits = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; var sortedDigits = from d in digits orderby d.Length, d select d; use a CollectionView for your listbox and add a SortDescription ICollectionView

How do I bind to a ListBox in IronPython?

别等时光非礼了梦想. 提交于 2020-01-01 14:37:37
问题 I am just starting out using IronPython with WPF and I don't quiet understand how binding is supposed to be done. Normally in WPF I would just do something like this: <ListBox Name="MyListBox"> <ListBox.Resources> <Style TargetType="ListBoxItem"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <DockPanel> <TextBlock Text="{Binding Path=From}" /> <TextBlock Text="{Binding Path=Subject}" /> </DockPanel> </DataTemplate> </Setter.Value> </Setter> </Style> </ListBox.Resources> <

How to get item list from wxpython ListBox

安稳与你 提交于 2020-01-01 14:35:19
问题 Is there a single method that returns the list of items contained in a wxPython listBox? I cant seem to find anything anywhere in the documentation or anywhere for that matter. All that I can think to do is to set the selection to all of the items and then get the selected items, though seems like an ugly roundabout way of doing something that should be simple. Update: As pointed out by jeremy the way to do this is with GetStrings() e.g. listBoxList = yourListBox.GetStrings() 回答1: wx.ListBox

Selecting multiple Listbox items through code

空扰寡人 提交于 2020-01-01 11:37:41
问题 Hi there I have searched for a while now and can't seem to find a solution to my problem, I have tried multiple methods to select multiple items in my listbox through code however none have worked, The best result I got was 1 selected item in my listbox. Basically I want to select multiple items of the same value. below is my code, sorry if I seem newbie but I am new to programming and still learning basic stuff. foreach (string p in listBox1.Items) { if (p == searchstring) { index = listBox1

Selecting multiple Listbox items through code

白昼怎懂夜的黑 提交于 2020-01-01 11:37:22
问题 Hi there I have searched for a while now and can't seem to find a solution to my problem, I have tried multiple methods to select multiple items in my listbox through code however none have worked, The best result I got was 1 selected item in my listbox. Basically I want to select multiple items of the same value. below is my code, sorry if I seem newbie but I am new to programming and still learning basic stuff. foreach (string p in listBox1.Items) { if (p == searchstring) { index = listBox1

Tkinter Listbox

自闭症网瘾萝莉.ら 提交于 2020-01-01 11:23:14
问题 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:55
问题 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.