listboxitem

WP7 - Animating add/remove item in a ListBox

假装没事ソ 提交于 2019-12-01 01:43:24
问题 I know you can achieve this in Silverlight 4 by playing with the ListBoxItem style's LayoutStates, i.e. BeforeUnloaded, BeforeLoaded and AfterLoaded. It doesn't seem to be working at all in WP7 although these states exist in the default style. I am currently using version 7.1. Is there any way I can get this working? Thanks, Xin 回答1: for this I used Artefact Animator, it's for Silverlight but works perfectly for WP7 also. The code shows only the addition. Whole code from the project's sample

How to animate ListBox Items on MouseEnter and MouseLeave events using C#/WPF?

时光总嘲笑我的痴心妄想 提交于 2019-12-01 00:33:13
I can't capture/trigger OnMouseEnter or OnMouseLeave events through C# code for list items. To be clear, I don't need an OnSelectedItem event. What I want to do is to be able to handle the OnMouseEnter and OnMouseLeave events for ListBoxItem which will start the DoubleAnimation for that ListBoxItem - I want to enlarge its font on MouseEnter and restore to original size on MouseLeave. Any ideas? Thanks. Something like this (as part of the ListBox's DataTemplate): <DataTemplate.Triggers> <EventTrigger SourceName="BorderControl" RoutedEvent="TextBlock.MouseEnter"> <BeginStoryboard> <Storyboard>

How to animate ListBox Items on MouseEnter and MouseLeave events using C#/WPF?

坚强是说给别人听的谎言 提交于 2019-11-30 18:07:52
问题 I can't capture/trigger OnMouseEnter or OnMouseLeave events through C# code for list items. To be clear, I don't need an OnSelectedItem event. What I want to do is to be able to handle the OnMouseEnter and OnMouseLeave events for ListBoxItem which will start the DoubleAnimation for that ListBoxItem - I want to enlarge its font on MouseEnter and restore to original size on MouseLeave. Any ideas? Thanks. 回答1: Something like this (as part of the ListBox's DataTemplate): <DataTemplate.Triggers>

Why can't I set the background color of a selected ListBoxItem in WPF?

心不动则不痛 提交于 2019-11-30 15:39:10
问题 When a user clicks on an ListBoxItem, I want to it to be a bold larger font red background yellow Everything works except the background. It seems that there is a standard (blue) background for the selected item. How do I override that and change the selected background yellow? Here is the code: <Window x:Class="AlternateListBox2.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width=

Stretch ListBox Items hit area to full width of the ListBox? ListBox style is set implicity through a theme

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 11:46:02
I've looked around for an answer on this, but the potential duplicates are more concerned with presentation than interaction. I have a basic list box, and each item's content is a simple string. The ListBox itself is stretched to fill it's grid container, but each ListBoxItem's hitarea does not mirror the ListBox width. It looks as if the hitarea (pointer contact area) for each item is only the width of the text content. How do I make this stretch all the way across, regardless of the text size. I've set HorizontalContentAlignment to Stretch, but this doesn't solve my problem. My only other

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

久未见 提交于 2019-11-30 02:56:09
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="True"> <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment,

WPF: how do i handle a click on a ListBox item?

对着背影说爱祢 提交于 2019-11-30 00:49:55
问题 In my WPF app I'm handling a ListBox SelectionChanged event and it runs fine. Now I need to handle a click event (even for the already selected item); I've tried MouseDown but it does not work. How can I handle a ListBox click on an item? 回答1: Just handle PreviewMouseDown event: private void listBox_PreviewMouseDown(object sender, MouseButtonEventArgs e) { var item = ItemsControl.ContainerFromElement(listBox, e.OriginalSource as DependencyObject) as ListBoxItem; if (item != null) { // ListBox

WPF - How to combine DataTrigger and Trigger?

我的未来我决定 提交于 2019-11-29 23:11:48
NOTE I have asked the related question: How to combine DataTrigger and EventTrigger? I have a list box containing several items. The item's class implements INotifyPropertyChanged and has a property IsAvailable . I use that property to indicate unavailable options in the list using a different colour. However, if a selected item is not available, then the foreground colour should be red. <ListBox> <ListBox.Resources> <DataTemplate DataType="{x:Type local:InstitutionViewModel}"> <TextBlock Name="Name" Text="{Binding Name}"/> <DataTemplate.Triggers> <DataTrigger Binding="{Binding IsAvailable}"

WPF ListBoxItems with DataTemplates - How do I reference the CLR Object bound to ListBoxItem from within the DataTemplate?

£可爱£侵袭症+ 提交于 2019-11-29 18:48:54
问题 I have a ListBox, that's bound to an ObservableCollection . Each ListBoxItem is displayed with a DataTemplate . I have a button in my DataTemplate , that when clicked, needs a reference to the member of the ObservableCollection it's part of the DataTemplate for. I can't use the ListBox.SelectedItem property because the item does not become selected when clicking the button. So either: I need to figure out how to properly set ListBox.SelectedItem when the mouse hovers, or when the button is

How to access Visibility property of the ListBoxItems

与世无争的帅哥 提交于 2019-11-29 11:29:33
In my WPF program I have a ListBox control: <ListBox x:Name="mailsListBox" SelectionChanged="mailsListBox_SelectionChanged" > <ListBoxItem Content="..." Background="#FFF3F3F3" Margin="0,0,0,1" /> <ListBoxItem Content="...." Margin="0,0,0,1" Visibility="Hidden"/> </ListBox> How can I access Visibility property of the ListBoxItems ? My code doesn't works: mailsListBox.Items[1].Visibility = Visible; Like this: (mailsListBox.Items[1] as ListBoxItem).Visibility = Visibility.Visible; Or you can use ItemContainerGenerator.ContainerFromItem method: ((ListBoxItem)(mailsListBox.ItemContainerGenerator