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 6211977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:25:51+00:00 2026-05-24T06:25:51+00:00

I try to implement a ListBox where the selected item is displayed in more

  • 0

I try to implement a ListBox where the selected item is displayed in more detail than the others. One approach is shown by Josh Smith on his blog.

To enhance the user experience, I’d like to animate the change (i.e. the item growing larger, additional information fading in).
Using the DataTriggers Enter- or ExitActions to start Storyboard has the disadvandates, that

  • I have no reusable template for the detailed view (it just exists as the end state of an animation).
  • Every change to the detailed view hs to be worked in at the two animations instead of just once.

Is there another approach thats more easily maintainable?

  • 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-24T06:25:52+00:00Added an answer on May 24, 2026 at 6:25 am

    You could use this ListBox.ItemContainerStyle and adjust it for your needs.

    <Style TargetType="{x:Type ListBoxItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">                                
                    <Border>
                        <StackPanel>
                            <ContentPresenter x:Name="Compact"
                                    Opacity="1"
                                    ContentTemplate="{StaticResource UnselectedDataTemplate}">
                                <ContentPresenter.LayoutTransform>
                                    <ScaleTransform ScaleY="1" />
                                </ContentPresenter.LayoutTransform>
                            </ContentPresenter>
    
                            <ContentPresenter x:Name="Details"
                                    Opacity="0"
                                    ContentTemplate="{StaticResource SelectedDataTemplate}">
                                <ContentPresenter.LayoutTransform>
                                    <ScaleTransform ScaleY="0" />
                                </ContentPresenter.LayoutTransform>
                            </ContentPresenter>
                        </StackPanel>
    
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup Name="SelectionStates">
                                <VisualState Name="Unselected">
                                    <Storyboard SpeedRatio="2">
                                        <DoubleAnimation To="1"
                                                Storyboard.TargetName="Compact"
                                                Storyboard.TargetProperty="Opacity" />
                                        <DoubleAnimation To="1"
                                                Storyboard.TargetName="Compact"
                                                Storyboard.TargetProperty="LayoutTransform.(ScaleTransform.ScaleY)" />
                                        <DoubleAnimation To="0"
                                                Storyboard.TargetName="Details"
                                                Storyboard.TargetProperty="Opacity" />
                                        <DoubleAnimation To="0"
                                                Storyboard.TargetName="Details"
                                                Storyboard.TargetProperty="LayoutTransform.(ScaleTransform.ScaleY)" />
                                    </Storyboard>
                                </VisualState>
    
                                <VisualState Name="Selected">
                                    <Storyboard SpeedRatio="2">
                                        <DoubleAnimation To="0"
                                                Storyboard.TargetName="Compact"
                                                Storyboard.TargetProperty="Opacity" />
                                        <DoubleAnimation To="0"
                                                Storyboard.TargetName="Compact"
                                                Storyboard.TargetProperty="LayoutTransform.(ScaleTransform.ScaleY)" />
                                        <DoubleAnimation To="1"
                                                Storyboard.TargetName="Details"
                                                Storyboard.TargetProperty="Opacity" />
                                        <DoubleAnimation To="1"
                                                Storyboard.TargetName="Details"
                                                Storyboard.TargetProperty="LayoutTransform.(ScaleTransform.ScaleY)" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Border>                            
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    

    In this case I have declared the templates as resources.

    <DataTemplate x:Key="UnselectedDataTemplate">
        /* your controls for unselected state */
    </DataTemplate>
    <DataTemplate x:Key="SelectedDataTemplate">
        /* your controls for selected state */
    </DataTemplate>
    

    But I think binding datatemplated content directly to ContentPresenter.Content is possible too.

    If Details are additional and not for replacement of Compact, simply remove all DoubleAnimation from Storyboard with Storyboard.TargetName="Compact".

    Hope this helps.

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

Sidebar

Related Questions

I Have two listboxes when I drag One item from the source listbox I
If I try to implement my class on this file I get an error
I've try to implement integration tests for a working application (spring, hibernate, soap, cxf).
If I try to implement this simple-as-possible example: Update Content with AJAXRefreshRequest it does
I had try to implement the send me log feature into my apps but
I would like to implement an B+ tree in Java and try to optimize
My first try of MVC. Am trying to implement a simple example. Inspiration from
i try to implement the accordion jquery for toggle slide down and slide up
I try to implement the following code: <div class=clearid=usernameline>username:<input type=text name=username id=username style=border:1px solid
I try to implement an RSA algorithm in a Java program. I am facing

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.