Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could use this <code>ListBox.ItemContainerStyle</code> and adjust it for your needs.</p> <pre><code>&lt;Style TargetType="{x:Type ListBoxItem}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type ListBoxItem}"&gt; &lt;Border&gt; &lt;StackPanel&gt; &lt;ContentPresenter x:Name="Compact" Opacity="1" ContentTemplate="{StaticResource UnselectedDataTemplate}"&gt; &lt;ContentPresenter.LayoutTransform&gt; &lt;ScaleTransform ScaleY="1" /&gt; &lt;/ContentPresenter.LayoutTransform&gt; &lt;/ContentPresenter&gt; &lt;ContentPresenter x:Name="Details" Opacity="0" ContentTemplate="{StaticResource SelectedDataTemplate}"&gt; &lt;ContentPresenter.LayoutTransform&gt; &lt;ScaleTransform ScaleY="0" /&gt; &lt;/ContentPresenter.LayoutTransform&gt; &lt;/ContentPresenter&gt; &lt;/StackPanel&gt; &lt;VisualStateManager.VisualStateGroups&gt; &lt;VisualStateGroup Name="SelectionStates"&gt; &lt;VisualState Name="Unselected"&gt; &lt;Storyboard SpeedRatio="2"&gt; &lt;DoubleAnimation To="1" Storyboard.TargetName="Compact" Storyboard.TargetProperty="Opacity" /&gt; &lt;DoubleAnimation To="1" Storyboard.TargetName="Compact" Storyboard.TargetProperty="LayoutTransform.(ScaleTransform.ScaleY)" /&gt; &lt;DoubleAnimation To="0" Storyboard.TargetName="Details" Storyboard.TargetProperty="Opacity" /&gt; &lt;DoubleAnimation To="0" Storyboard.TargetName="Details" Storyboard.TargetProperty="LayoutTransform.(ScaleTransform.ScaleY)" /&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState Name="Selected"&gt; &lt;Storyboard SpeedRatio="2"&gt; &lt;DoubleAnimation To="0" Storyboard.TargetName="Compact" Storyboard.TargetProperty="Opacity" /&gt; &lt;DoubleAnimation To="0" Storyboard.TargetName="Compact" Storyboard.TargetProperty="LayoutTransform.(ScaleTransform.ScaleY)" /&gt; &lt;DoubleAnimation To="1" Storyboard.TargetName="Details" Storyboard.TargetProperty="Opacity" /&gt; &lt;DoubleAnimation To="1" Storyboard.TargetName="Details" Storyboard.TargetProperty="LayoutTransform.(ScaleTransform.ScaleY)" /&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;/VisualStateManager.VisualStateGroups&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p><br /> In this case I have declared the templates as resources.</p> <pre><code>&lt;DataTemplate x:Key="UnselectedDataTemplate"&gt; /* your controls for unselected state */ &lt;/DataTemplate&gt; &lt;DataTemplate x:Key="SelectedDataTemplate"&gt; /* your controls for selected state */ &lt;/DataTemplate&gt; </code></pre> <p>But I think binding datatemplated content directly to <code>ContentPresenter.Content</code> is possible too.</p> <p><br /> If <strong>Details</strong> are additional and not for replacement of <strong>Compact</strong>, simply remove all <code>DoubleAnimation</code> from <code>Storyboard</code> with <code>Storyboard.TargetName="Compact"</code>.</p> <p><br /> Hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload