我想将TextBox
's Tag
(位于 a 内DataGrid
)绑定到验证规则的 CurrentLegStrategy 属性(即 a DependencyProperty
)。虽然我已经使用全局隧道对象对 Deal 依赖属性做了类似的事情,但是无法弄清楚 CurrentLegStrategy 的隧道是什么(理想情况下应该来自绑定数据到DataRow
或绑定数据到TextBox
标签)?
<DataTemplate x:Key="PremiumProp">
<TextBlock Style="{StaticResource TextBlockLeft}" Tag="{Binding Strategy}" x:Name="txtPremiumProp">
<TextBlock.Text>
<Binding Path="AbsolutePremium" StringFormat="{}{0:#,##0.00####}" Converter="{StaticResource _DoubleConvertor}">
<Binding.ValidationRules>
<Control:MBSStrategyBasedDoubleValidation ValidatesOnTargetUpdated="True" ValidationTag="premabs"
ErrorMessage="Please enter a valid positive (+) premium (also check the reference which is required for auto calculation)!">
<Control:MBSStrategyBasedDoubleValidation.Deal>
<Control:DealObject Deal="{Binding Tag, Source={StaticResource TradeTunnel}}" CurrentLegStrategy="{Binding Path=Tag, ElementName=txtPremiumProp}"/>
</Control:MBSStrategyBasedDoubleValidation.Deal>
</Control:MBSStrategyBasedDoubleValidation>
</Binding.ValidationRules>
</Binding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
然后我也试了,
<TextBlock.Resources>
<ResourceDictionary>
<FrameworkElement x:Name="strategySource" Tag="{Binding Tag, Source={x:Reference txtPremiumProp}}"/>
</ResourceDictionary>
</TextBlock.Resources>
具有以下内容:
CurrentLegStrategy="{Binding Path=Tag, Source={StaticResource strategySource}}"
找不到名为“strategySource”的资源。资源名称区分大小写。