What is a cached user in the context of a DataBinding?
I am getting 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'
I also use a converter to output the data stream: Target -> Source
and Source -> Target
.
In addition, I display the binding information for the attached property each time it changes.
The binding remains active, but Source and Target are not synchronized. I don't know what is the reason for this broken function and since VS2012 prints warning 106 in red I think the problem is somewhere near this message.
And here is the binding:
<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>
source to share
I really don't know WHY, but this street magic helped!
It was:
<Setter Property="Helpers:FocusHelper.IsFocused" Value="{Binding IsEnvelopeFocused,
Converter={StaticResource bdc},
PresentationTraceSources.TraceLevel=High}"/>
It has become:
<Setter Property="Helpers:FocusHelper.IsFocused" Value="{Binding DataContext.IsEnvelopeFocused,
Converter={StaticResource bdc},
PresentationTraceSources.TraceLevel=High,
RelativeSource={RelativeSource Self}}"/>
Changed the output of the data binding trace:
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 converter produced 'False'
System.Windows.Data Warning: 88 : BindingExpression (hash=52742621): TransferValue - using final value 'False'
And snapping now works both ways.
I think there is a problem with DataGonCell DataContext inheritance and style.
To be precise, the order is here, I suppose.
If style is applied, the Data Binding first tries to get the DataContext not yet inherited and something breaks the binding without triggering any updates.
I will try to reproduce this error, and if I succeed in doing so, I will write to MS Connect.
source to share