2012-02-14 122 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