我在我的XAML中绑定到具有样式属性的控件。控件和样式之间的WPF绑定
<TextBox x:Name="txtCapAmount" Text="{Binding Path=CapAmount}" Style="{DynamicResource AmountTextBoxStyle}" />
在款式,我想用从控制结合,但我不知道如何设置
<Style x:Key="AmountTextBoxStyle" TargetType="{x:Type TextBox}">
<EventSetter Event="TextBox.PreviewTextInput" Handler="PreviewTextInput_IsTheNewValueAnAcceptableAmount" />
<EventSetter Event="CommandManager.PreviewExecuted" Handler="CommandPaste_IsTheNewValueAnAcceptableAmount" />
<Setter Property="MinWidth" Value="100" />
<Setter Property="Text" Value="{Binding Path=?????, TargetNullValue={x:Static System:String.Empty}, StringFormat={}{0:C0}}" />
</Style>
我想重新使用这种风格在整个应用程序,但需要多个文本框将每个单独的文本框绑定到不同的属性。在样式中,是否可以在保留控件上的路径集的同时更改“文本”属性?
你有没有尝试装订路径=文本? – dnr3 2010-08-27 06:13:05