Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF. Must have non-null value for 'Property' for multitrigger condition

Tags:

c#

wpf

xaml

Have multitrigger, one of the conditions is not null, so if StowedAssetDetailedThumbnailViewModel != null then set template

<Style.Triggers>     <MultiTrigger>         <MultiTrigger.Conditions>             <Condition Property="IsSelected" Value="true" />             <Condition Binding="{Binding Path=StowedAssetDetailedThumbnailViewModel,                                          Converter={StaticResource isNull}}"                        Value="False"/>         </MultiTrigger.Conditions>         <Setter Property="Template" Value="{StaticResource SelectedTemplate}" />     </MultiTrigger> </Style.Triggers> 

Using simple converter:

return isNull == null; 

the error is Must have non-null value for Property

UPDATE: Thanks, the final solution is

<Style.Triggers>     <MultiDataTrigger>         <MultiDataTrigger.Conditions>             <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}"                        Value="true" />             <Condition Binding="{Binding Path=StowedAssetDetailedThumbnailViewModel,                                  Converter={StaticResource isNull}}"                                  Value="false"/>         </MultiDataTrigger.Conditions>          <Setter Property="Template" Value="{StaticResource SelectedTemplate}" />     </MultiDataTrigger> </Style.Triggers> 
like image 835
nelly2k Avatar asked Jan 13 '14 05:01

nelly2k


1 Answers

You'll want to use a MultiDataTrigger in this case. A MultiTrigger can only be triggered by dependency properties.

like image 136
Patrick Y Avatar answered Sep 22 '22 17:09

Patrick Y