listbox

Difference between ListView and ListBox in Visual Studio

試著忘記壹切 提交于 2019-12-29 05:45:48
问题 What is the difference between "ListView" and "ListBox" in a "Windows 8" app. 回答1: The ListBox is an older control primarily for compatibility with other xaml frameworks. The ListView has build-in functionality for touch etc. Use the ListView unless you have a specific need for the ListBox See here for more detail. Specific events available only for ListView : DragItemsStarting ItemClick Methods: CompleteViewChange CompeteViewChangeFrom CompleteViewChangeTo InitializeViewChange

Why is ListBoxFor not selecting items, but ListBox is?

余生颓废 提交于 2019-12-29 03:28:08
问题 I have the following code in my view: <%= Html.ListBoxFor(c => c.Project.Categories, new MultiSelectList(Model.Categories, "Id", "Name", new List<int> { 1, 2 }))%> <%= Html.ListBox("MultiSelectList", new MultiSelectList(Model.Categories, "Id", "Name", new List<int> { 1, 2 }))%> The only difference is that the first helper is strongly typed (ListBoxFor), and it fails to show the selected items (1,2), even though the items appear in the list, etc. The simpler ListBox is working as expected. I'm

How do I draw the selected list-box item in a different color?

随声附和 提交于 2019-12-29 01:32:46
问题 Is is possible to change the item selection focus color and text color in a TListBox? When themes are not enabled in the project, or the list box style is set to owner-draw, the selection around the item is painted blue, which I believe is globally defined by the system's appearance settings. I would like to change the color of selected items to a custom color. So an example, the result would be something like this: Note the last listbox has been modified in Paint to illustrate the example.

Change style of last item in ListBox

两盒软妹~` 提交于 2019-12-28 06:35:12
问题 I have listbox control which has list of colors. Here is code and Image: <ListBox Name="FillSelections" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Center" SelectedItem="{Binding SelectedColor}" SelectionMode="Single" Style="{StaticResource HorizontalListBoxStyle}" ItemsSource="{Binding FillColors}" ItemTemplate="{StaticResource ColorsItemTemplate}"></ListBox> <DataTemplate x:Key="ColorsItemTemplate"> <Border BorderBrush="Transparent"> <Rectangle Width="20" StrokeThickness=

An ItemsControl is inconsistent with its items source - WPF Listbox

南楼画角 提交于 2019-12-28 05:59:18
问题 I have a WPF window containing a ListBox control that is populated when a button click method is executed. XAML: <ListBox Name="ThirdPartyListBox" ItemsSource="{Binding}" Margin="0,70,0,0"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <Image Source="C:\Users\Test\Desktop\Project\ACME-WPF\ACME-WPF\window-new-3.ico" Margin="5" Width="50"/> <Button Name="ThirdPartyInstallButton" Content="Install" Click="InstallThirdPartyUpdatesButton_Click" Margin="5,5,0,0" Height=

An ItemsControl is inconsistent with its items source - WPF Listbox

天大地大妈咪最大 提交于 2019-12-28 05:59:12
问题 I have a WPF window containing a ListBox control that is populated when a button click method is executed. XAML: <ListBox Name="ThirdPartyListBox" ItemsSource="{Binding}" Margin="0,70,0,0"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <Image Source="C:\Users\Test\Desktop\Project\ACME-WPF\ACME-WPF\window-new-3.ico" Margin="5" Width="50"/> <Button Name="ThirdPartyInstallButton" Content="Install" Click="InstallThirdPartyUpdatesButton_Click" Margin="5,5,0,0" Height=

How do I make a WPF data template fill the entire width of the listbox?

狂风中的少年 提交于 2019-12-28 04:54:11
问题 I have a ListBox DataTemplate in WPF. I want one item to be tight against the left side of the ListBox and another item to be tight against the right side, but I can't figure out how to do this. So far I have a Grid with three columns, the left and right ones have content and the center is a placeholder with it's width set to "*". Where am I going wrong? Here is the code: <DataTemplate x:Key="SmallCustomerListItem"> <Grid HorizontalAlignment="Stretch"> <Grid.RowDefinitions> <RowDefinition/> <

How do you programmatically set focus to the SelectedItem in a WPF ListBox that already has focus?

≡放荡痞女 提交于 2019-12-28 03:46:05
问题 We want to set the SelectedItem of a ListBox programmatically and want that item to then have focus so the arrow keys work relative to that selected item. Seems simple enough. The problem however is if the ListBox already has keyboard focus when setting SelectedItem programmatically, while it does properly update the IsSelected property on the ListBoxItem , it doesn't set keyboard focus to it, and thus, the arrow keys move relative to the previously-focused item in the list and not the newly

Select ListBoxItem if TextBox in ItemTemplate gets focus

孤人 提交于 2019-12-28 03:06:15
问题 I have added a DataTemplate to a ListBox class to bind my collection to: <ListBox x:Name="lstEmails" Height="259" Margin="12,0,12,41" Width="276" SelectionChanged="lstEmails_SelectionChanged"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <Label Visibility="Hidden" Content="{Binding ID}"></Label> <TextBox Width="200" Text="{Binding EmailAddress}"></TextBox> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> This does exactly what I want it to do.

How to call an action stored in Dictionary? [closed]

不羁岁月 提交于 2019-12-25 20:02:45
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I am attempting to setup a dictionary that will then have its keys stored as items in a listbox . I have been able to establish a