wpf - 触发器上的属性不能为空

标签 wpf xaml dependency-properties

<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: 

我不知道可能有什么问题。异常(exception)太模糊:哪个属性(property)?什么是空?

最佳答案

仔细检查 PositioningMethodProperty 的 DependencyProperty 定义 - 确保拥有的类型实际上是定义 DP 的类。

关于wpf - 触发器上的属性不能为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9274361/

相关文章:

WPF-MVVM 将 ViewModel-Property 绑定(bind)到嵌套的 UserControl

c# - 按小数点对齐值

c# - MVVM,对ViewModelLocator和DataTemplate感到困惑,导致ViewFirst vs ViewModel First

wpf - 如何在 VB.Net 3.0 中声明依赖属性

wpf - WPF中如何显示多层控件?

c# - 本地化 WPF 应用程序不起作用?

xaml - Appbar 按钮图标图像在 Window 8.1 中似乎不正确

wpf - 将 WPF 设计数据与 MVVM 模式一起使用

c# - 如何使用 PropertyChangedCallBack

wpf - 将数据传递给 mvvm 用户控件