Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 371645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:08:03+00:00 2026-05-12T14:08:03+00:00

I have the following code snippet (copy and paste into kaxaml, xamlpad, etc to

  • 0

I have the following code snippet (copy and paste into kaxaml, xamlpad, etc to try it)
that collapses all but the selected item. However, I want to revert back to all visible
when the mouse is not over the ListBox and I just cannot get it to work short of going code behind. I am using the IsMouseOver ListBox property to set selected item properties on the ListBox to attempt to trigger an update but no luck.
Any ideas?

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Grid> <ListBox Name="lb" Width="100" Height="100" Background="Red" SelectionMode="Single"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <UniformGrid Columns="1"/> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBoxItem Background="AliceBlue">Item 1 </ListBoxItem> <ListBoxItem Background="Aquamarine">Item </ListBoxItem> <ListBoxItem Background="Azure">Item </ListBoxItem> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="Visibility" Value="Visible"/> <Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="False"/> <Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}},Path=SelectedItems.Count}" Value="1"/> </MultiDataTrigger.Conditions> <MultiDataTrigger.EnterActions> <BeginStoryboard> <Storyboard Duration="0:0:1"> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0:0:1" Value="{x:Static Visibility.Collapsed}"/> </ObjectAnimationUsingKeyFrames> <DoubleAnimation Duration="0:0:1" Storyboard.TargetProperty="Opacity" To="0"/> </Storyboard> </BeginStoryboard> </MultiDataTrigger.EnterActions> </MultiDataTrigger> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True"/> <Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}},Path=SelectedItems.Count}" Value="1"/> </MultiDataTrigger.Conditions> <MultiDataTrigger.EnterActions> <BeginStoryboard> <Storyboard Duration="0:0:0"> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}"/> </ObjectAnimationUsingKeyFrames> <DoubleAnimation Duration="0:0:0" Storyboard.TargetProperty="Opacity" To="1"/> </Storyboard> </BeginStoryboard> </MultiDataTrigger.EnterActions> </MultiDataTrigger> </Style.Triggers> </Style> </ListBox.ItemContainerStyle> <ListBox.Style> <Style> <Style.Triggers> <Trigger Property="ListBox.IsMouseOver" Value="False"> <Setter Property="ListBox.SelectedItem" Value="{x:Null}"/> <Setter Property="ListBoxItem.IsSelected" Value="False"/> <Setter Property="ListBox.SelectedIndex" Value="-1"/> </Trigger> <EventTrigger RoutedEvent="Mouse.MouseLeave"> <BeginStoryboard> <Storyboard> <Int32Animation Duration="0:0:0" Storyboard.TargetProperty="SelectedIndex" To="-1"/> </Storyboard> </BeginStoryboard> </EventTrigger> </Style.Triggers> </Style> </ListBox.Style> </ListBox> </Grid> </Page>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:08:04+00:00Added an answer on May 12, 2026 at 2:08 pm

    Move your style to resources and apply it when the mouse is over the ListBox.`

    <Page.Resources>
        <Style x:Key="CustomStyle" TargetType="{x:Type ListBoxItem}">
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="False"/>
                        <Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}},Path=SelectedItems.Count}" Value="1"/>
                    </MultiDataTrigger.Conditions>
                    <MultiDataTrigger.EnterActions>
                        <BeginStoryboard>
                            <Storyboard Duration="0:0:1">
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:1" Value="{x:Static Visibility.Collapsed}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <DoubleAnimation Duration="0:0:1" Storyboard.TargetProperty="Opacity" To="0"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </MultiDataTrigger.EnterActions>
                    <MultiDataTrigger.ExitActions>
                        <BeginStoryboard>
                            <Storyboard Duration="0:0:0">
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <DoubleAnimation Duration="0:0:0" Storyboard.TargetProperty="Opacity" To="1"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </MultiDataTrigger.ExitActions>
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>
    </Page.Resources>
    
    <Grid>
        <ListBox
           Name="lb"
           Width="100"
           Height="100"
           Background="Red"
           SelectionMode="Single">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid Columns="1"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBoxItem Background="AliceBlue">Item 1
            </ListBoxItem>
            <ListBoxItem Background="Aquamarine">Item
            </ListBoxItem>
            <ListBoxItem Background="Azure">Item
            </ListBoxItem>
            <ListBox.Style>
                <Style>
                    <Style.Triggers>
                        <Trigger Property="ListBox.IsMouseOver" Value="True">
                            <Setter 
                                Property="ListBox.ItemContainerStyle" 
                                Value="{StaticResource CustomStyle}"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </ListBox.Style>
        </ListBox>
    </Grid>
    

    `
    Also note the usage of the MultiDataTrigger.ExitActions, these are the actions to apply when the trigger object becomes inactive.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code snippet that i use to compile class at the run
I have the following code snippet embedded into some of my divs so when
I have the following code snippet from my PowerShell script that... Loops through a
I have the following code snippet. I'm trying to list all the files in
I have following code snippet but I am getting wrong output. class Program {
I have following code snippet into c# public class Client { public string ID
I have the following code snippet which uses'event' My fellow developers argue that the
I have following code snippet: class ABC{ public: int a; void print(){cout<<hello<<endl;} }; int
I have the following code snippet. $items['A'] = Test; $items['B'] = Test; $items['C'] =
I have the following code snippet where some strings are initialized in the if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.