Note that there are some explanatory texts on larger screens.

plurals
  1. POHighlight TreeView item being dragged over
    text
    copied!<p>In my application, I have a TreeView that allows drag/drop. I have all the functionality working fine, however I am having difficulty highlighting a TreeViewItem when it is dragged over. Here is my style for my treeview item. The IsMouseOver trigger does not work while dragging, because dragging seems to block other mouse events. Can anyone help me trigger the same border changes on my treeview item while dragging?</p> <pre><code>&lt;Style x:Key="TreeViewItemStyle" TargetType="{x:Type TreeViewItem}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type TreeViewItem}"&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition MinWidth="19" Width="Auto"/&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;ColumnDefinition Width="*"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;RowDefinition/&gt; &lt;/Grid.RowDefinitions&gt; &lt;ToggleButton x:Name="PART_Expander" Style="{StaticResource ExpandCollapseToggleStyle}" IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press" /&gt; &lt;Border x:Name="OuterBorder" Grid.Column="1" SnapsToDevicePixels="True" BorderThickness="1" CornerRadius="3" BorderBrush="Transparent" Background="Transparent" &gt; &lt;Border x:Name="InnerBorder" SnapsToDevicePixels="True" BorderThickness="1" CornerRadius="2" BorderBrush="Transparent" Background="Transparent" &gt; &lt;ContentPresenter x:Name="PART_Content" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" /&gt; &lt;/Border&gt; &lt;/Border&gt; &lt;ItemsPresenter x:Name="PART_ItemsHost" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" /&gt; &lt;/Grid&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsMouseOver" SourceName="OuterBorder" Value="True"&gt; &lt;Setter TargetName="OuterBorder" Property="BorderBrush" Value="Blue" /&gt; &lt;Setter TargetName="OuterBorder" Property="Background" Value="Red" /&gt; &lt;Setter TargetName="InnerBorder" Property="BorderBrush" Value="White" /&gt; &lt;/Trigger&gt; &lt;MultiTrigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre>
 

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