我正在尝试设置一些绑定。还有,我正在使用MVVM模式。
<Grid.Resources>
<src:ActivityViewToToolTipContentConverter x:Key="tooltipConverter"></src:ActivityViewToToolTipContentConverter>
<SolidColorBrush x:Key="CustomNonWorkingBrush" Color="#DFE9F2" Opacity="0.75"/>
</Grid.Resources>
<gantt:GanttControl Name="GanttChart"
IDBinding="{Binding TaskID}"
NameBinding="{Binding TaskName}"
IndentLevelBinding="{Binding IndentLevel}"
StartTimeBinding="{Binding StartDate}"
PredecessorIndicesBinding="{Binding PredecessorIndices}"
DescriptionBinding="{Binding TaskResponsible}"
SortOrderBinding="{Binding SortOrder}"
ToolTipContentBinding="{Binding ActualTaskResponsibleDepartment, Converter={StaticResource tooltipConverter}}" //It is this line I am talking about
TemplateApplied="GanttChart_TemplateApplied"
CanUserReorderRows="True"
NonWorkingTimeBackground="{StaticResource CustomNonWorkingBrush}"
SyncRowBackgrounds="True"
AdjustDurationOnAssignment="False"
DependencyLineAdded="GanttChart_DependencyLineChanged"
DependencyLineRemoved="GanttChart_DependencyLineChanged"
Loaded="GanttChart_Loaded"
/>
我的转换器位于另一个名为“ActivityViewToToolTipContentConverter.cs”的文件中
当我运行代码时,我得到了这个例外:
System.Windows.Data错误:40:BindingExpression路径错误: 'object'上找不到'ActualTaskResponsibleDepartment'属性 ''GanttActivityView'(Name ='')'。 BindingExpression:路径= ActualTaskResponsibleDepartment; DataItem ='GanttActivityView'(Name ='');目标元素是'ToolTip' (名称= 'TaskTooltip'); target属性是'Content'(类型'Object')
答案 0 :(得分:3)
当绑定失败时,从未与转换器有任何关系,并且错误明确表示您尝试绑定到在DataContext视图上找不到的属性。
答案 1 :(得分:2)
您的DataContext(绑定到GanttActivityView)是否属性为ActualTaskResponsibleDepartment?