在我的WPF应用程序输出中,我收到此消息> 错误:
System.Windows.Data Error: 17 : Cannot get 'Item[]' value (type 'TeamStandingData') from 'TeamStandingDatas' (type 'ObservableCollection`1'). BindingExpression:Path=Standing.TeamStandingDatas[2].Win; DataItem='Workspace' (HashCode=58914672); target element is 'TextBox' (Name='textBox1_Copy5'); target property is 'Text' (type 'String') ArgumentOutOfRangeException:'System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
我假设这是因为我在WPF绑定中使用[2]。(可能在没有值时显示)?
我得出的结论是,我没有使用数组,而是尝试在数组中创建每个元素的实例并以这种方式绑定它,消息就消失了。
在这两种情况下,应用程序都可以正常工作(有或没有数组),但我更喜欢该集合,因为在我的情况下数据更易于管理等。
WPF:
<TextBox x:Name="textBox1_Copy5" Text="{Binding Standing.TeamStandingDatas[2].Win}" HorizontalAlignment="Left" Height="38" Margin="129,264,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="46"/>
我的应用程序编译得很好并按预期工作,但看到这条消息意味着我做错了什么或达不到一个好的标准?