在我的silverlight应用程序中,我在页面上有一系列文本框,它们都以相同的方式绑定。在代码隐藏中,我设置每个数据上下文。有没有人使用样式来融入这个通用绑定功能?Silverlight 4数据绑定与样式
例 我page.xaml
<TextBox Name="txtTest" Style="{StaticResource ItemTextBoxInt}"/>
在我Styles.xaml
<Resource Dictionary>
<Style x:Key="ItemTextBoxInt" TargetType="TextBox">
<Setter Property="Text" Value="{Binding Amount, Mode=TwoWay, StringFormat=\{0:n0\}}"/>
</Style>
,这将引发对启动
{系统在App.xaml.cs错误。 Windows.Markup.XamlParseException:设置属性''引发异常。 [Line:9 Position:36] ---> System.NotSupportedException:不能设置只读属性''。 在MS.Internal.XamlMemberInfo.SetValue(对象目标,对象的值) 在MS.Internal.XamlManagedRuntimeRPInvokes.SetValue(XamlTypeToken法菜单,XamlQualifiedObject & inObj,XamlPropertyToken inProperty,XamlQualifiedObject & inValue) ---内部异常堆栈跟踪的结尾--- 在System.Windows.Application.LoadComponent(对象组件,乌里resourceLocator) 在STARS_Silverlight.App.InitializeComponent() 在STARS_Silverlight.App..ctor()}
任何人都知道这是可能的如果是的话,正确的方法来完成这个?
-Andrew
该金额确实有公开曝光的二传手。仍然会抛出同样的错误。 :( – Andrew 2011-02-03 23:19:30