Reputation: 139
Hopefully this is obvious to an experienced WPF user. When binding do I have to consider the (embedded) level of the target that I am binding to?
In the XAML below I have MyTextBox which can accept a list of my own additional validationRules, FileNameValidationRule has a ValidPathStr of type PathStr which has a InputPathStr string dependency property.
To test my theory I tried setting the binding of the Text of the MyTextBox to the same binding as the InputPathStr for MyTextBox. The binding of the Text seemed to work (although incorrectly, but it still attempted to resolve the binding) but the binding to InputPathStr gave a 'Framework mentor not found' error. The trace below shows the output, the first chunk being the Text binding and the second chunk being the failed InputPathStr binding.
I expected the bindings to either both work or both fail, how should I alter the binding for InputPathStr to make it work as it does for Text?
Thanks.
<my2:MyTextBox x:Name="m_renameTextBox"
Text="{Binding Path=SourceBrowseDir.ItemFullPath, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" >
<my2:MyTextBox.AdditionalValidationRules>
<src:FileNameValidationRule>
<src:FileNameValidationRule.ValidPathStr>
<src:PathStr InputPathStr="{Binding Path=SourceBrowseDir.ItemFullPath, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"/>
</src:FileNameValidationRule.ValidPathStr>
</src:FileNameValidationRule>
</my2:MyTextBox.AdditionalValidationRules>
</my2:MyTextBox >
the output is:
> Created BindingExpression (hash=3780752) for Binding (hash=63892678)
Path: 'SourceBrowseDir.ItemFullPath'
BindingExpression (hash=3780752): Attach to ScreenControls.HelperUserControls.MyTextBox.Text (hash=20793123)
BindingExpression (hash=3780752): Resolving source
BindingExpression (hash=3780752): Found data context element: MyTextBox (hash=20793123) (OK)
BindingExpression (hash=3780752): Activate with root item PresetsNavigatorViewModel (hash=34365244)
BindingExpression (hash=3780752): At level 0 using cached accessor for PresetsNavigatorViewModel.SourceBrowseDir: RuntimePropertyInfo(SourceBrowseDir)
BindingExpression (hash=3780752): Replace item at level 0 with PresetsNavigatorViewModel (hash=34365244), using accessor RuntimePropertyInfo(SourceBrowseDir)
BindingExpression (hash=3780752): GetValue at level 0 from PresetsNavigatorViewModel (hash=34365244) using RuntimePropertyInfo(SourceBrowseDir): <null>
BindingExpression (hash=3780752): Item at level 1 is null - no accessor
BindingExpression (hash=3780752): TransferValue - got raw value {DependencyProperty.UnsetValue}
BindingExpression (hash=3780752): TransferValue - using fallback/default value ''
BindingExpression (hash=3780752): TransferValue - using final value ''
>
> Created BindingExpression (hash=56631954) for Binding (hash=47211710)
Path: 'SourceBrowseDir.ItemFullPath'
BindingExpression (hash=56631954): Attach to ScreenControls.Helper.PathStr.InputPathStr (hash=40208759)
BindingExpression (hash=56631954): Use Framework mentor <null>
BindingExpression (hash=56631954): Resolving source
BindingExpression (hash=56631954): Framework mentor not found
BindingExpression (hash=56631954): Resolve source deferred
Upvotes: 1
Views: 2702