listbox

Multiselect ListBox

痞子三分冷 提交于 2019-11-29 03:04:24
I'm having trouble in multiple items selection in an ListBox. I've tried deriving new control from Selector and writing ListBox helper class which did not work (as expected). The issue with Selector class is, it does not expose SelectedItems and it's hell to bind the property and manipulate it with selection changed event. The issue with ListBox Helper class is, I'm getting the required data on multiple selection but it never hits the bound property. Does anybody know a better way to implement multiselect listbox? Thanks in advance... The ListBox has multiple selection already implemented.

formcollection only holds the selected html.listbox items values? MVC

冷暖自知 提交于 2019-11-29 02:38:53
问题 My scenario is this: I have two listbox's, one that contains all my database items, and an empty one. The user adds the items needed from the full listbox to the empty listbox. I'm using a form to submit all the items the user has added. The problem is, only the selected items from the listbox are submitted. So if the user deselects some of the items, they wont be submitted in the form. My view looks like so: <% using (Html.BeginForm("MyAction", "MyController")) { %> <%= Html.ListBox(

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

混江龙づ霸主 提交于 2019-11-29 02:25:36
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 the mouse and starts the drag-operation with this item. Is there a good workaround for this problem or

How to get or compute actual width of ListBox without Vertical Scrollbar if visible

筅森魡賤 提交于 2019-11-29 02:03:26
I wonder how to get or compute actual width of ListBox without Vertical Scrollbar if visible. What I want to do is changing width of each items inside ListBox without being covered by Vertical Scrollbar . Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}} At least, above binding tell me the actual width of ListBox , but this one does not handle width of vertical scrollbar. Is there any good way to solve this? Try binding to the ViewportWidth property of the containing ScrollViewer instead. Like this: Width="{Binding Path=ViewportWidth,

ListBoxItem selection on TextBox focus

心已入冬 提交于 2019-11-29 01:48:17
I have a ListBox showing items using the following DataTemplate: <DataTemplate x:Key="PersonTemplate" DataType="{x:Type DAL:ResultItem}" > <StackPanel Width="280" > <TextBox BorderThickness="0" IsReadOnly="True" Background="Transparent" Text="{Binding FullName1, Mode=OneWay}"/> ... </StackPanel> </DataTemplate> I am using a transparent, read-only, borderless TextBox as opposed to a TextBlock because I want users to be able to select the text for copying. Should I do it differently? How can I write this so that when the user clicks on the TextBox, the ListBoxItem gets selected as well? Thanks!

How to move item in listBox up and down?

雨燕双飞 提交于 2019-11-29 01:44:50
问题 I have a listBox1 object and it contains some items. I have a button to move selected item up and another to move selected item down. What should the code be to the two buttons? 回答1: private void UpClick() { // only if the first item isn't the current one if(listBox1.ListIndex > 0) { // add a duplicate item up in the listbox listBox1.AddItem(listBox1.Text, listBox1.ListIndex - 1); // make it the current item listBox1.ListIndex = (listBox1.ListIndex - 2); // delete the old occurrence of this

How to fix an Excel listbox that can't scroll the last element into view

末鹿安然 提交于 2019-11-29 01:36:36
A killer problem I've had in excel UIs since as long as I can remember, is with listbox scrolling. When you have more elements in a listbox that can be displayed, a scoll bar will appear. In certain conditions, however, scrolling the bar all the way to the bottom of the list and releasing it, will "jump" the bar a notch upwards, and you won't be able to see the last item in the list. This is illustrated here: There are many forum posts presenting this issue, and the solution has always been "Set the integral height property to false, and then set it to true again." What this does is slightly

WPF: ListBox with WrapPanel, vertical scrolling problem

我们两清 提交于 2019-11-29 01:10:18
I have a UserControl (XAML below) that has a ListBox that I want to display images inside a WrapPanel, where images are displayed as many as will fit on one row and then wrap onto the next row etc. It works, except when the ListBox grows higher than the available space in the window, I'm not getting a vertical scrollbar, i.e. the contents get clipped. If I set a fixed height on the ListBox, the scrollbar appears and works as expected. How can I get this listbox to grow to the available space and then show a vertical scrollbar? This control is inside StackPanel inside a Grid in the main window.

UserControl as DataTemplate inside ListBox

你说的曾经没有我的故事 提交于 2019-11-29 00:21:23
问题 I want to reuse my UserControls in other UserControls like page or window as DataTemplates, in this example inside a ListBox. Everything is MVVM. I've a UserControl called "CardControl" to display a simple object "Card". Card has two Properties, "ID" and "CardImage". The controls DataContext is set via XAML. If I open this UserControl in VS or Blend it shows me the dummy Card that I have defined in the corresponding ViewModel. Now I have another UserControl called "CardSetControl", which

ListBoxItem produces “System.Windows.Data Error: 4” binding error

China☆狼群 提交于 2019-11-28 23:49:05
问题 I have created the fallowing ListBox : <ListBox x:Name="RecentItemsListBox" Grid.Row="1" BorderThickness="0" Margin="2,0,0,0" SelectionChanged="RecentItemsListBox_SelectionChanged"> <ListBox.Resources> <Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}"> <Style.Triggers> <!--This trigger is needed, because RelativeSource binding can only succeeds if the current ListBoxItem is already connected to its visual parent--> <Trigger Property="IsVisible" Value=