listbox

How can I make some items in a ListBox bold?

你离开我真会死。 提交于 2019-11-30 08:45:44
In Visual c# Express Edition, is it possible to make some (but not all) items in a ListBox bold? I can't find any sort of option for this in the API. You need to change listbox's DrawMode to DrawMode.OwnerDrawFixed. Check out these articles on msdn: DrawMode Enumeration ListBox.DrawItem Event Graphics.DrawString Method Also look at this question on msdn forums: Question on ListBox items A simple example (both items - Black-Arial-10-Bold): public partial class Form1 : Form { public Form1() { InitializeComponent(); ListBox1.Items.AddRange(new Object[] { "First Item", "Second Item"}); ListBox1

Changing WPF Listbox SelectedItem text color and highlight/background Color using C#

≯℡__Kan透↙ 提交于 2019-11-30 08:44:10
问题 I am trying to change the highlighted(selected) color and the highlighted text color of a wpf listbox at runtime. I have tried creating a style and applying it as follows: Style s = new Style(typeof(ListBox)); s.Resources.Add(SystemColors.HighlightBrushKey, Setting.ListSelectedColor); s.Resources.Add(SystemColors.HighlightTextBrushKey, Setting.ListSelectedTextColor); lstGames.Style = s; But this seems to do nothing. Is there any way to achieve this? EDIT: Per suggestions, I tried using

Gaps between items in my ListBox

戏子无情 提交于 2019-11-30 07:59:21
When I create ListBox with horizontal items ordering for example like this: <DockPanel> <ListBox> <ListBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel Orientation="Horizontal" /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBoxItem> <Button Content="Hello" /> </ListBoxItem> <ListBoxItem> <Button Content="Hello" /> </ListBoxItem> </ListBox> </DockPanel> I have small gaps between buttons in the list as indicated by the arrows on following picture: How can I get rid of those gaps please ? I need to have items in ListBox just next to each other. I have tried changing ItemTemplate

ListBox select all items

可紊 提交于 2019-11-30 07:49:18
问题 I need to select all items in a ListBox when a CheckBox is clicked. Is it possible to select all items in the ListBox using a single line of code? Or will I have to loop through all items and set selected to true for each one of them? Thanks :) 回答1: I think you have to loop here. Selecting all items at once is a pretty specific (and probably rare) use case where it simply makes no sense to offer that functionality out of the box. Furthermore, the loop will be just two lines of code anyway.

TextBox, Button and ListBox in a ListBox

女生的网名这么多〃 提交于 2019-11-30 07:42:36
问题 I have a listbox with a bunch of contols in each list item. <ListBox x:Name="projectList" IsSynchronizedWithCurrentItem="True"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Name}" /> <ListBox x:Name="taskList" ItemsSource="{Binding Tasks}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Name}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <TextBox x:Name="textBoxTask" /> <Button x:Name="ButtonAddNewTask"

In a WPF ListBox with more than 1000 Image Items the Zoom Images become slow

旧城冷巷雨未停 提交于 2019-11-30 07:09:09
I met a problem when deveoping a photo viewer application. I use ListBox to Show Images, which is contained in a ObservableCollection. I bind the ListBox's ItemsSource to the ObservableCollection. <DataTemplate DataType="{x:Type modeldata:ImageInfo}"> <Image Margin="6" Source="{Binding Thumbnail}" Width="{Binding ZoomBarWidth.Width, Source={StaticResource zoombarmanager}}" Height="{Binding ZoomBarWidth.Width, Source={StaticResource zoombarmanager}}"/> </DataTemplate> <Grid DataContext="{StaticResource imageinfolder}"> <ScrollViewer VerticalScrollBarVisibility="Auto"

WPF Trigger for IsSelected in a DataTemplate for ListBox items

半城伤御伤魂 提交于 2019-11-30 06:14:37
问题 I have a listbox, and I have the following ItemTemplate for it: <DataTemplate x:Key="ScenarioItemTemplate"> <Border Margin="5,0,5,0" Background="#FF3C3B3B" BorderBrush="#FF797878" BorderThickness="2" CornerRadius="5"> <DockPanel> <DockPanel DockPanel.Dock="Top" Margin="0,2,0,0"> <Button HorizontalAlignment="Left" DockPanel.Dock="Left" FontWeight="Heavy" Foreground="White" /> <Label Content="{Binding Path=Name}" DockPanel.Dock="Left" FontWeight="Heavy" Foreground="white" /> <Label

How to pass listbox selecteditem as command parameter in a button?

ぃ、小莉子 提交于 2019-11-30 06:04:19
Here is my situation: <ListBox ItemsSource="{Binding Path=AvailableUsers}"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Id}"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <Button Command="{Binding Path=Load}" CommandParameter={???? What goes here ????}/> What I want is to pass the Id that is currently selected in the ListBox. I have a viewmodel behind the scenes that essentially looks like this: public class ViewModel : DependencyObject { ICommand Load { get; set; } // dependency property but I didn't bother to write it out like one List<User> AvailableUsers {

WPF binding to Listbox selectedItem

喜欢而已 提交于 2019-11-30 05:56:49
问题 Can anyone help with the following - been playing about with this but can't for the life of me get it to work. I've got a view model which contains the following properties; public ObservableCollection<Rule> Rules { get; set; } public Rule SelectedRule { get; set; } In my XAML I've got; <ListBox x:Name="lbRules" ItemsSource="{Binding Path=Rules}" SelectedItem="{Binding Path=SelectedRule, Mode=TwoWay}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text

Changing scroll-bars color of a ListBox on Windows Phone 7

泪湿孤枕 提交于 2019-11-30 05:44:45
问题 I have a <ListBox> item with a white background, I want to change the scroll-bars color so that they can be visible when the user scrolls the items. How can I achieve this? 回答1: You can change the VisualState of the Scrolling state. You want to edit the ListBox's ScrollViewer's VerticalScrollBar template. For example, this style is 100% opacity and red: <Style x:Key="ScrollViewerStyle1" TargetType="ScrollViewer"> <Setter Property="VerticalScrollBarVisibility" Value="Auto"/> <Setter Property=