ItemsControl中的WPF多维int数组具有双向
我有一个多维整数数组(向量),我想用ItemsControl中的WPF多维int数组具有双向,wpf,multidimensional-array,itemscontrol,two-way-binding,Wpf,Multidimensional Array,Itemscontrol,Two Way Binding,我有一个多维整数数组(向量),我想用TextBox作为DataTemplate显示在ItemsControl中。我使用绑定到向量列表,它是一个列表。int[,]不起作用,因为ItemSource必须是一维的,所以我将其转换为List 此绑定到向量列表单向工作时,文本框都正确显示。但是,two-way不起作用,ItemsControl的ItemSource不会更改,VectorList也不会更新。我做错了什么 XAML: 好的,我现在只使用网格,手动读取/设置文本框。更简单,也更有效:)我还使用
TextBox
作为DataTemplate
显示在ItemsControl
中。我使用绑定
到向量列表
,它是一个列表ItemSource
必须是一维的,所以我将其转换为List绑定到向量列表单向工作时,文本框都正确显示。但是,two-way
不起作用,ItemsControl
的ItemSource
不会更改,VectorList
也不会更新。我做错了什么
XAML:
好的,我现在只使用网格,手动读取/设置文本框。更简单,也更有效:)我还使用了Int[]
复选框0-false,1-true。它是只读的,但不更新源代码Int[]
。为什么?它是相同的ItemsControl
binding。。
<ItemsControl x:Name="itemsControl" ItemTemplate="{DynamicResource DataTemplate_Level1}" ItemsSource="{Binding VectorList, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<DataTemplate x:Key="DataTemplate_Level2">
<TextBox Text="{Binding Path=., Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Height="35" Width="40"/>
</DataTemplate>
<DataTemplate x:Key="DataTemplate_Level1">
<ItemsControl ItemsSource="{Binding Path=.}" ItemTemplate="{DynamicResource DataTemplate_Level2}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</DataTemplate>