2013-01-24 48 views
1

我得到的結合此跟蹤信息:什麼是DataBinding上下文中的緩存處理器?

System.Windows.Data Warning: 55 : Created BindingExpression (hash=45919010) for Binding (hash=4523055) 
    System.Windows.Data Warning: 57 : Path: 'IsEnvelopeFocused' 
    System.Windows.Data Warning: 59 : BindingExpression (hash=45919010): Default mode resolved to TwoWay 
    System.Windows.Data Warning: 60 : BindingExpression (hash=45919010): Default update trigger resolved to PropertyChanged 
    System.Windows.Data Warning: 61 : BindingExpression (hash=45919010): Attach to System.Windows.Controls.DataGridCell.IsFocused (hash=42777048) 
    System.Windows.Data Warning: 66 : BindingExpression (hash=45919010): Resolving source 
    System.Windows.Data Warning: 69 : BindingExpression (hash=45919010): Found data context element: DataGridCell (hash=42777048) (OK) 
    System.Windows.Data Warning: 77 : BindingExpression (hash=45919010): Activate with root item VulnerEnvelope (hash=53089570) 

    System.Windows.Data Warning: 106 : BindingExpression (hash=45919010): At level 0 using cached 
accessor for VulnerEnvelope.IsEnvelopeFocused: RuntimePropertyInfo(IsEnvelopeFocused) 

    System.Windows.Data Warning: 103 : BindingExpression (hash=45919010): Replace item at level 0 with VulnerEnvelope (hash=53089570), using accessor RuntimePropertyInfo(IsEnvelopeFocused) 
    System.Windows.Data Warning: 100 : BindingExpression (hash=45919010): GetValue at level 0 from VulnerEnvelope (hash=53089570) using RuntimePropertyInfo(IsEnvelopeFocused): 'False' 
    System.Windows.Data Warning: 79 : BindingExpression (hash=45919010): TransferValue - got raw value 'False' 

我也用轉換器的輸出數據流:Target -> SourceSource -> Target
除此之外,我在每次更改時輸出附加屬性的綁定信息。
綁定保持活動狀態,但源和目標不同步。我不知道這個功能損壞的原因是什麼,VS2012以紅色打印警告106,我認爲問題出在這個消息附近。

這裏是結合:

<DataGridTemplateColumn Width="*" CanUserResize="True" CanUserSort="True" Header=" Title " 
               SortMemberPath="."> 
    <DataGridTemplateColumn.CellStyle> 
    <Style TargetType="DataGridCell"> 
     <Setter Property="Helpers:FocusHelper.IsFocused" Value="{Binding IsEnvelopeFocused, Converter={StaticResource bdc}, PresentationTraceSources.TraceLevel=High}"/> 
    </Style> 
    </DataGridTemplateColumn.CellStyle> 
    <DataGridTemplateColumn.CellTemplate> 
    <DataTemplate> 
     <TextBlock Name="txtTitle" VerticalAlignment="Center"> 
     <TextBlock.Text> 
      <MultiBinding Converter="{StaticResource TitleConverter}" UpdateSourceTrigger="PropertyChanged"> 
      <Binding Path="." /> 
      <Binding Path="DataContext.Language" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=UserControl}" /> 
      </MultiBinding> 
     </TextBlock.Text> 
     </TextBlock> 
    </DataTemplate> 
    </DataGridTemplateColumn.CellTemplate> 
</DataGridTemplateColumn> 

回答

1

我真的不知道爲什麼,但這種街頭魔術幫助!

它是:

<Setter Property="Helpers:FocusHelper.IsFocused" Value="{Binding IsEnvelopeFocused, 
           Converter={StaticResource bdc}, 
           PresentationTraceSources.TraceLevel=High}"/> 

它變成了:

<Setter Property="Helpers:FocusHelper.IsFocused" Value="{Binding DataContext.IsEnvelopeFocused, 
           Converter={StaticResource bdc}, 
           PresentationTraceSources.TraceLevel=High, 
           RelativeSource={RelativeSource Self}}"/> 

數據綁定跟蹤輸出改變:

System.Windows.Data Warning: 55 : Created BindingExpression (hash=52742621) for Binding (hash=33023833) 
System.Windows.Data Warning: 57 : Path: 'DataContext.IsEnvelopeFocused' 
System.Windows.Data Warning: 59 : BindingExpression (hash=52742621): Default mode resolved to TwoWay 
System.Windows.Data Warning: 60 : BindingExpression (hash=52742621): Default update trigger resolved to PropertyChanged 
System.Windows.Data Warning: 61 : BindingExpression (hash=52742621): Attach to System.Windows.Controls.DataGridCell.IsFocused (hash=34022436) 
System.Windows.Data Warning: 66 : BindingExpression (hash=52742621): Resolving source 
System.Windows.Data Warning: 69 : BindingExpression (hash=52742621): Found data context element: <null> (OK) 
System.Windows.Data Warning: 71 : RelativeSource.Self found DataGridCell (hash=34022436) 
System.Windows.Data Warning: 77 : BindingExpression (hash=52742621): Activate with root item DataGridCell (hash=34022436) 
System.Windows.Data Warning: 106 : BindingExpression (hash=52742621): At level 0 using cached accessor for DataGridCell.DataContext: DependencyProperty(DataContext) 

System.Windows.Data Warning: 103 : BindingExpression (hash=52742621): Replace item at level 0 with DataGridCell (hash=34022436), using accessor DependencyProperty(DataContext) 
System.Windows.Data Warning: 100 : BindingExpression (hash=52742621): GetValue at level 0 from DataGridCell (hash=34022436) using DependencyProperty(DataContext): VulnerEnvelope (hash=14963839) 

System.Windows.Data Warning: 106 : BindingExpression (hash=52742621): At level 1 using cached accessor for VulnerEnvelope.IsEnvelopeFocused: RuntimePropertyInfo(IsEnvelopeFocused) 

System.Windows.Data Warning: 103 : BindingExpression (hash=52742621): Replace item at level 1 with VulnerEnvelope (hash=14963839), using accessor RuntimePropertyInfo(IsEnvelopeFocused) 
System.Windows.Data Warning: 100 : BindingExpression (hash=52742621): GetValue at level 1 from VulnerEnvelope (hash=14963839) using RuntimePropertyInfo(IsEnvelopeFocused): 'False' 
System.Windows.Data Warning: 79 : BindingExpression (hash=52742621): TransferValue - got raw value 'False' 
System.Windows.Data Warning: 81 : BindingExpression (hash=52742621): TransferValue - user's converter produced 'False' 
System.Windows.Data Warning: 88 : BindingExpression (hash=52742621): TransferValue - using final value 'False' 

現在結合工作中左右逢源。
我認爲DataGridCell的DataContext繼承和樣式應用程序存在一個問題。
準確的說,這裏的順序很重要,我想。
如果先應用Style,則數據綁定會嘗試獲取尚未繼承的DataContext,並以某種方式破壞綁定而不會導致更新。
我會試着重現這個錯誤,如果我設法做到這一點,我會寫信給MS Connect。

相關問題