2012-02-14 83 views
1
<Style TargetType="controls:EventTimeView">  
    <Style.Triggers>   
     <Trigger Property="PositioningMethod" Value="Column" > 
      <Setter Property="Background" Value="Black" /> 
     </Trigger> 
    </Style.Triggers> 
</Style> 

PositioningMethod是枚举类型的EventTimeView的依赖项属性。触发器的属性不能为空

结果:

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: 

我不知道什么可能是错误的。例外情况太模糊:哪个属性?什么是空?

回答

10

仔细检查您的DependencyProperty定义PositioningMethodProperty - 确保拥有的类型其实是在其中DP定义的类。

+0

现货!谢谢 – Zoman 2012-10-15 17:30:10

0

尝试喜欢的款式事先设置的背景属性:

<Style TargetType="controls:EventTimeView"> 
    <Setter Property="Background" Value="Transparent" /> 

    <Style.Triggers>   
     <Trigger Property="PositioningMethod" Value="Column" > 
      <Setter Property="Background" Value="Black" /> 
     </Trigger> 
    </Style.Triggers> 
</Style> 
+0

没有区别 – Abstractor 2012-02-14 13:26:43