Note that there are some explanatory texts on larger screens.

plurals
  1. POTrigger within a Style to Set the Properties of a Control in a ControlTemplate
    text
    copied!<p>What I have now:</p> <pre><code>&lt;Style TargetType="{x:Type ListBox}" x:Key="PhotoListBoxStyle"&gt; &lt;Style.Triggers&gt; &lt;Trigger Property="{Binding Path=IsChecked, ElementName=DetailView}" Value="False"&gt; &lt;Setter TargetName="WrapPanelItem" Property="ItemHeight" Value="100" /&gt; &lt;Setter TargetName="WrapPanelItem" Property="ItemWidth" Value="400" /&gt; &lt;/Trigger&gt; &lt;/Style.Triggers&gt; &lt;Setter Property="Foreground" Value="White" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type ListBox}" &gt; &lt;WrapPanel Name="WrapPanelItem" Margin="5" IsItemsHost="True" Orientation="Horizontal" ItemHeight="{Binding Value, ElementName=ZoomSlider }" ItemWidth="{Binding Value, ElementName=ZoomSlider }" VerticalAlignment="Top" HorizontalAlignment="Stretch" /&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>The closest I got was to add the Name to the WrapPanel to try and reference from the Trigger above it, but the TargetName cannot be found. I also tried creating a separate style attached to the WrapPanel directly, but that caused issues with controls using the PhotoListBoxStyle that was it's parent:</p> <pre><code>&lt;Style x:Key="WrapPanelSetter" TargetType="{x:Type WrapPanel}"&gt; &lt;Setter Property="ItemHeight" Value="{Binding Value, ElementName=ZoomSlider }" /&gt; &lt;Setter Property="ItemWidth" Value="{Binding Value, ElementName=ZoomSlider }" /&gt; &lt;Setter Property="HorizontalAlignment" Value="Stretch" /&gt; &lt;Setter Property="VerticalAlignment" Value="Top" /&gt; &lt;Setter Property="Orientation" Value="Horizontal" /&gt; &lt;Setter Property="Margin" Value="5" /&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding Path=IsChecked, ElementName=DetailView}" Value="False"&gt; &lt;Setter Property="ItemHeight" Value="100" /&gt; &lt;Setter Property="ItemWidth" Value="400" /&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; </code></pre> <p>Thanks for any help. I am more than willing to try a different approach if there is a better option!</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