WPF/Silverlight のバインディングの問題に取り組んでいます。私は Listview ウィッチを EF linq クエリからの DataContext で埋めています。同じユーザーコントロールにはテキストボックスがあります。それらの値を変更すると、リストビューが更新され、de db bij .SaveChanges でデータが変更されます。問題は、コンボボックスを使用するとデータは保存されますが、リストビューが更新されないことです。
お役に立てますか???? ここにxamlがあります
<ListView Grid.Row="1" Grid.Column="0" Margin="4,4,4,0" x:Name="controlsListBox" Grid.RowSpan="7" ItemsSource="{Binding}" SelectedValuePath="ID" LostFocus="controlsListBox_LostFocus">
<ListView.View>
<GridView>
<GridViewColumn Width="25" Header="Rw" DisplayMemberBinding="{Binding RowNr}"/>
<GridViewColumn Width="25" Header="Cl" DisplayMemberBinding="{Binding ColumnNr}"/>
<GridViewColumn Width="100" Header="Name" DisplayMemberBinding="{Binding Name}"/>
<GridViewColumn Width="25" Header="Tb" DisplayMemberBinding="{Binding TabIndex}"/>
<GridViewColumn Width="100" Header="Type" DisplayMemberBinding="{Binding ControlTypes.Name}"/>
<GridViewColumn Width="100" Header="Text" DisplayMemberBinding="{Binding TextResources.Text}"/>
</GridView>
</ListView.View>
</ListView>
<Label Grid.Row="2" Grid.Column="5" Height="23" Margin="4,4,4,0" x:Name="rowSpanLabel" VerticalAlignment="Top"
Content="RowNr"/>
<TextBox Grid.Row="2" Grid.Column="6" Height="23" Margin="4,4,4,0" x:Name="rowSpanTextBox" VerticalAlignment="Top"
Text="{Binding Path=SelectedItem.RowNr, ElementName=controlsListBox}"/>
<Label Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" Height="23" Margin="4,4,4,0" x:Name="controlTypeLabel" VerticalAlignment="Top"
Content="Type"/>
<ComboBox Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="5" Height="23" Margin="4,4,4,0" x:Name="controlTypeComboBox" VerticalAlignment="Top"
DataContext="{Binding Path=ControlTypes, ElementName=controlsListBox}" IsSynchronizedWithCurrentItem="True" DisplayMemberPath="Name"
SelectedItem="{Binding Path=SelectedItem.ControlTypes, ElementName=controlsListBox, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
/>
そして、ここに C# コードがあります: _controlProperties.Clear(); var data = (_dataContext.ControlProperties の x から x.FormProperties.ID == 1 orderby x.RowNr, x.ColumnNr, x.Name select x); foreach (var item in data) { item.TextResourcesReference.Load(); _controlProperties.Add(アイテム); } // 良い結果を得るには、最初に DataContext を null に設定する必要があります。controlsListBox.DataContext = null; controlsListBox.DataContext = _controlProperties;
controlTypeComboBox.DataContext = (from c in _dataContext.ControlTypes
orderby c.Name
select c).ToList();