Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Move your style to resources and apply it when the mouse is over the ListBox.`</p> <pre><code>&lt;Page.Resources&gt; &lt;Style x:Key="CustomStyle" TargetType="{x:Type ListBoxItem}"&gt; &lt;Style.Triggers&gt; &lt;MultiDataTrigger&gt; &lt;MultiDataTrigger.Conditions&gt; &lt;Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="False"/&gt; &lt;Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}},Path=SelectedItems.Count}" Value="1"/&gt; &lt;/MultiDataTrigger.Conditions&gt; &lt;MultiDataTrigger.EnterActions&gt; &lt;BeginStoryboard&gt; &lt;Storyboard Duration="0:0:1"&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0:0:1" Value="{x:Static Visibility.Collapsed}"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;DoubleAnimation Duration="0:0:1" Storyboard.TargetProperty="Opacity" To="0"/&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/MultiDataTrigger.EnterActions&gt; &lt;MultiDataTrigger.ExitActions&gt; &lt;BeginStoryboard&gt; &lt;Storyboard Duration="0:0:0"&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;DoubleAnimation Duration="0:0:0" Storyboard.TargetProperty="Opacity" To="1"/&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/MultiDataTrigger.ExitActions&gt; &lt;/MultiDataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/Page.Resources&gt; &lt;Grid&gt; &lt;ListBox Name="lb" Width="100" Height="100" Background="Red" SelectionMode="Single"&gt; &lt;ListBox.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;UniformGrid Columns="1"/&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ListBox.ItemsPanel&gt; &lt;ListBoxItem Background="AliceBlue"&gt;Item 1 &lt;/ListBoxItem&gt; &lt;ListBoxItem Background="Aquamarine"&gt;Item &lt;/ListBoxItem&gt; &lt;ListBoxItem Background="Azure"&gt;Item &lt;/ListBoxItem&gt; &lt;ListBox.Style&gt; &lt;Style&gt; &lt;Style.Triggers&gt; &lt;Trigger Property="ListBox.IsMouseOver" Value="True"&gt; &lt;Setter Property="ListBox.ItemContainerStyle" Value="{StaticResource CustomStyle}"/&gt; &lt;/Trigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/ListBox.Style&gt; &lt;/ListBox&gt; &lt;/Grid&gt; </code></pre> <p> ` Also note the usage of the MultiDataTrigger.ExitActions, these are the actions to apply when the trigger object becomes inactive.</p>
    singulars
    1. This table or related slice is empty.
    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.
    3. VO
      singulars
      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