在DataBinding的上下文中缓存的教授是什么? [英] What is a Cached acessor in the context of DataBinding?
问题描述
我获取绑定的跟踪信息:
I get this trace information for the binding:
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'
我还使用转换器输出数据流:目标 - >来源
和来源 - >目标
。
除此之外,我还会在每次更改时输出附加属性的绑定信息。
绑定保持活动状态,但是源和目标不同步。我不知道这个破坏功能的原因是什么,VS2012打印警告106红色我认为问题在这个消息附近。
I also use converter to output data flow: Target -> Source
and Source -> Target
.
Besides this I output binding information for attached property at its every change.
Binding stays active but Source and Target do not synchronize. I don't know what is the cause of this broken functionality and as VS2012 prints Warning 106 in red I think the problem is somewhere near this message.
这里是绑定:
<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>
推荐答案
我真的不知道为什么这个街头魔术有帮助
I realy do not know WHY but this street magic helped!
它是:
<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}}"/>
数据绑定跟踪输出已更改:
Data binding trace output changed:
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'
现在绑定有两种方式。 $ b我认为DataGridCell的DataContext继承和风格应用有一个标志。
确定这个顺序在这里是重要的,我想,如果Style被应用firs数据绑定尝试不继承DataContext,并以某种方式中断绑定,不会更新。
我将尝试重现这个错误,如果我设法完成,我将写入MS Connect 。
And binding now works in both ways.
I thinks there's a broblem with DataGridCell's DataContext inheritance and style appplication.
To be exact the order matters here, I suppose.
If Style is applied first Data Binding tries to get not yet inherited DataContext and that somehow breaks binding causing no updates.
I'll try to reproduce this bug and if I manage to do it, I'll write to MS Connect.
这篇关于在DataBinding的上下文中缓存的教授是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!