listboxitem

Set Interaction.Triggers to ListBoxItem

笑着哭i 提交于 2019-12-02 07:40:37
问题 I have set Interaction.Triggers to ListBox and perform respective TargetedTriggerAction when 'SelectionChanged' event occurs, like below. <ListBox x:Name="WorksheetListBox" ItemsSource="{Binding WorkSheetCollection}" ItemTemplate="{StaticResource workSheetTemplate}"> <i:Interaction.Triggers> <i:EventTrigger EventName="SelectionChanged"> <action:WorksheetListBoxAction /> </i:EventTrigger> </i:Interaction.Triggers> </ListBox> But my requirement is I need to set Interaction.Triggers to

Change ListBoxItem Background Color when mouse is over on the listBoxItem

断了今生、忘了曾经 提交于 2019-12-02 06:48:32
问题 I need to set change background color for list item when mouse is over. Here is my code: <DataTemplate x:Key="ListBoxSubCategoryListTemplate" DataType="{x:Type ListBoxItem}"> <StackPanel> <Button x:Name="btnSubCategoryList" Template="{StaticResource subCategoryListItems}" Content="{Binding Path=sub_category_name}" Background="Transparent" Height="25"/> </StackPanel> </DataTemplate> <ControlTemplate x:Key="subCategoryListItems" TargetType="{x:Type Button}"> <StackPanel FlowDirection=

Set Interaction.Triggers to ListBoxItem

我与影子孤独终老i 提交于 2019-12-02 03:46:29
I have set Interaction.Triggers to ListBox and perform respective TargetedTriggerAction when 'SelectionChanged' event occurs, like below. <ListBox x:Name="WorksheetListBox" ItemsSource="{Binding WorkSheetCollection}" ItemTemplate="{StaticResource workSheetTemplate}"> <i:Interaction.Triggers> <i:EventTrigger EventName="SelectionChanged"> <action:WorksheetListBoxAction /> </i:EventTrigger> </i:Interaction.Triggers> </ListBox> But my requirement is I need to set Interaction.Triggers to ListBoxItem's 'PreviewMouseDown' event(Note: ListBox populated via ItemsSource) You can try something like this:

Change ListBoxItem Background Color when mouse is over on the listBoxItem

前提是你 提交于 2019-12-02 02:54:57
I need to set change background color for list item when mouse is over. Here is my code: <DataTemplate x:Key="ListBoxSubCategoryListTemplate" DataType="{x:Type ListBoxItem}"> <StackPanel> <Button x:Name="btnSubCategoryList" Template="{StaticResource subCategoryListItems}" Content="{Binding Path=sub_category_name}" Background="Transparent" Height="25"/> </StackPanel> </DataTemplate> <ControlTemplate x:Key="subCategoryListItems" TargetType="{x:Type Button}"> <StackPanel FlowDirection="LeftToRight" Orientation="Horizontal" > <TextBlock Width="150" Height="{TemplateBinding Button.Height}" x:Name=

How to get the ListBoxItem for an item in ListBox on “bind-time”

南笙酒味 提交于 2019-12-02 01:49:15
问题 I have a ListBox with Foo objects, and based on some events I disable/enable the ListBoxItems in the ListBox. Using the ListBox.Items property I find Foo objects, and from what I've understood I need to use the following function to get the ListBoxItem container for the Foo. Correct? foreach (var item in Items) { var lbi = ItemContainerGenerator.ContainerFromItem(foo) as ListBoxItem; // do something } Actually I have a custom control FilteringListBox which inherit ListBox and adds an extra

How to get the ListBoxItem for an item in ListBox on “bind-time”

喜你入骨 提交于 2019-12-02 01:19:20
I have a ListBox with Foo objects, and based on some events I disable/enable the ListBoxItems in the ListBox. Using the ListBox.Items property I find Foo objects, and from what I've understood I need to use the following function to get the ListBoxItem container for the Foo. Correct? foreach (var item in Items) { var lbi = ItemContainerGenerator.ContainerFromItem(foo) as ListBoxItem; // do something } Actually I have a custom control FilteringListBox which inherit ListBox and adds an extra property to it. The above code is in the code behind of the custom control and works just fine when the

ObservableCollection and ListBoxItem DataTemplate generation problem

自闭症网瘾萝莉.ら 提交于 2019-12-01 09:09:35
问题 Something strange is going on with ObservableCollection. I have the following code: private readonly ObservableCollection<DisplayVerse> _display; private readonly ListBox _box; private void TransferToDisplay() { double elementsHeight = 0; _display.Clear(); for (int i = 0; i < _source.Count; i++) { DisplayVerse verse = _source[i]; _display.Add(verse); elementsHeight += CalculateItemsHeight(i); if (elementsHeight + Offset > _box.ActualHeight) { _display.RemoveAt(_display.Count - 1); break; } }

How to use IsKeyboardFocusWithin and IsSelected together?

瘦欲@ 提交于 2019-12-01 04:42:55
I have a style defined for my ListBoxItems with a trigger to set a background color when IsSelected is True: <Style x:Key="StepItemStyle" TargetType="{x:Type ListBoxItem}"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="OverridesDefaultStyle" Value="true"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ListBoxItem"> <Border Name="Border" Padding="0" SnapsToDevicePixels="true"> <ContentPresenter /> </Border> <ControlTemplate.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter TargetName="Border" Property="Background" Value="

Listbox “IsSelected” binding only partially working

廉价感情. 提交于 2019-12-01 04:05:29
问题 I have a ListBox that I populate dynamically via a binding (this is defined in a DataTemplate , which is why the binding is somewhat unusual): <ListBox SelectionMode="Extended" ItemsSource="{Binding DataContext.ResultList, RelativeSource={RelativeSource AncestorType=Window}}"> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="IsSelected" Value="{Binding IsSelected}"/> </Style> </ListBox.ItemContainerStyle> <ListBox.ItemTemplate> <DataTemplate> <Label

How to use IsKeyboardFocusWithin and IsSelected together?

烈酒焚心 提交于 2019-12-01 02:05:59
问题 I have a style defined for my ListBoxItems with a trigger to set a background color when IsSelected is True: <Style x:Key="StepItemStyle" TargetType="{x:Type ListBoxItem}"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="OverridesDefaultStyle" Value="true"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ListBoxItem"> <Border Name="Border" Padding="0" SnapsToDevicePixels="true"> <ContentPresenter /> </Border> <ControlTemplate.Triggers>