Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to change properties on a sub item in a DataTemplate using triggers from the containing control?
    text
    copied!<p>I want to change the background colour of the rectangle in the IsMouseOver trigger, is this possible?</p> <pre><code>&lt;Window&gt; &lt;Window.Resources&gt; &lt;DataTemplate x:Key="StackListViewItemTemplate"&gt; &lt;Grid&gt; &lt;Rectangle RadiusX="5" RadiusY="5" &gt; &lt;Rectangle.Fill&gt; &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt; &lt;GradientStop Color="#FF000000" Offset="0"/&gt; &lt;GradientStop Color="{Binding Path=Events.Colour}" Offset="1"/&gt; &lt;/LinearGradientBrush&gt; &lt;/Rectangle.Fill&gt; &lt;/Rectangle&gt; &lt;TextBlock FontSize="18pt" Grid.RowSpan="2" Text="{Binding Path=Events.Name}" HorizontalAlignment="Center" VerticalAlignment="Center" /&gt; &lt;/Grid&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;/Window.Resources&gt; &lt;Grid &gt; &lt;ListView ItemTemplate="{DynamicResource StackListViewItemTemplate}"&gt; &lt;ListView.ItemContainerStyle&gt; &lt;Style TargetType="{x:Type ListViewItem}"&gt; &lt;Style.Triggers&gt; &lt;Trigger Property="IsMouseOver" Value="true"&gt; &lt;!-- Here I want to set the background colour of the Rectangle in the DataTemplate --&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsSelected" Value="true"&gt; &lt;!-- Same here --&gt; &lt;/Trigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/ListView.ItemContainerStyle&gt; &lt;/ListView&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p><strong>Edit:</strong></p> <pre><code>&lt;Setter Property="Background" Value="Yellow"/&gt; </code></pre> <p>Is there a way to bind the Property value of the setter to child controls?</p>
 

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