Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting the tag property of a button to an integer value and firing a trigger
    primarykey
    data
    text
    <p>I want to do something like the following but it doesn't work. I want to use a datatrigger to set an integer (or whatever type) value to the Tag Property of a button i define inside my datatemplate. And then inside the button's image style fire a trigger when the corresponding value is set to the tag property of the button. But it doesn't seem to be working this way. If i set an x:Null value i can fire the trigger, that means the logic is ok. But setting a value like 0 or 1 doesn't fire the trigger. Any solutions?</p> <pre><code>&lt;DataTemplate x:Key="SomeDataTemplateofSomeType"&gt; &lt;Button x:Name="ButtonVisible"&gt; &lt;Button.Template&gt; &lt;ControlTemplate TargetType="Button"&gt; &lt;Image x:Name="FxImage"&gt; &lt;Image.Style&gt; &lt;Style TargetType="{x:Type Image}"&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding Tag, RelativeSource={RelativeSource TemplatedParent},UpdateSourceTrigger=PropertyChanged}" Value="0"&gt; &lt;Setter Property="Source" Value="/Resources/controls/images/fxiconsnone.png" /&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/Image.Style&gt; &lt;/Image&gt; &lt;/ControlTemplate&gt; &lt;/Button.Template&gt; &lt;/Button&gt; &lt;DataTemplate.Triggers&gt; &lt;DataTrigger Binding="{Binding Path=IsVisible, Value="True"&gt; &lt;Setter Property="Tag" TargetName="ButtonVisible" Value="1" /&gt; &lt;/DataTrigger&gt; &lt;DataTrigger Binding="{Binding Path=IsVisible, Value="False"&gt; &lt;Setter Property="Tag" TargetName="ButtonVisible" Value="0" /&gt; &lt;/DataTrigger&gt; &lt;/DataTemplate.Triggers&gt; &lt;/Datatemplate&gt; </code></pre>
    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. 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