Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property can not be null on Trigger

<Style TargetType="controls:EventTimeView">      
    <Style.Triggers>         
        <Trigger Property="PositioningMethod" Value="Column" >
            <Setter Property="Background" Value="Black" />
        </Trigger>
    </Style.Triggers>
</Style>

PositioningMethod is a dependency property of EventTimeView of an enum type.

Results in:

System.InvalidOperationException occurred
Message=Property can not be null on Trigger.
Source=PresentationFramework
StackTrace:
   at System.Windows.StyleHelper.UpdateTables(PropertyValue& propertyValue, FrugalStructList`1& childRecordFromChildIndex, FrugalStructList`1& triggerSourceRecordFromChildIndex, FrugalStructList`1& resourceDependents, HybridDictionary& dataTriggerRecordFromBinding, HybridDictionary childIndexFromChildName, Boolean& hasInstanceValues)
InnerException: 

I have no idea what might be wrong. The exception is too vague: which property? what is null?

like image 763
Abstractor Avatar asked Dec 01 '22 23:12

Abstractor


2 Answers

Double check your DependencyProperty definition for PositioningMethodProperty - make sure the owning type is in fact the class in which the DP is defined.

like image 97
Daniel Moore Avatar answered Dec 18 '22 03:12

Daniel Moore


I was getting this error because I was using Trigger instead of DataTrigger and I was binding the trigger to a property in the data context and not to a property in the control per se.

Once I changed the Trigger tag to DataTrigger, the error disappeared.

like image 42
Noah Bridge Avatar answered Dec 18 '22 01:12

Noah Bridge