Search code examples
wpfxamldependency-properties

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?


Solution

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