私はリストボックス.list box bind with dataset.listbox bindingが正しい結果を与えています.選択のためにリストボックスでチェックボックスを使用しましたが、それはうまく機能していますが、問題は、いくつかのアイテムリストボックスをチェックしてリストを下にスクロールするとボックスにチェックを入れて別のアイテムをチェックすると、スクロールダウンの上に戻り、ランダムに自動的にチェックが外されたアイテムが表示されます。項目のチェックを自動的に外したくありません。私を助けてください。以下のコードを使用します。
<DataTemplate x:Key="listBoxcontrycode">
<StackPanel Margin="4">
<DockPanel>
<CheckBox Name="chkcntrycode" Content="{Binding userisd}"
Checked="chkcntrycode_Checked" Unchecked="Unchkcntrycode_Checked" />
</DockPanel>
</StackPanel>
<ListBox Height="89" HorizontalAlignment="Left" ItemTemplate="{StaticResource listBoxcontrycode}" ItemsSource="{Binding Tables[0]}" Margin="160,0,0,6"
Name="listcntrycode" VerticalAlignment="Bottom" Width="86" Grid.Column="3" Grid.ColumnSpan="2" Grid.RowSpan="2"
OverridesDefaultStyle="False" SelectionMode="Extended" IsEnabled="True" Grid.Row="3" />
.
private void ListBoxBindingcntrycode()
{
DBConnection ob = new DBConnection();
RMS_Dataobject.getConnectionString = System.Configuration.ConfigurationSettings.AppSettings["EDM_RDMServer"];
string commandString = "use [" + cmbEDM.SelectedItem.ToString() + "] select userisd from ADS_Audit_Log";
DataTable dt = new DataTable();
dt = ob.ReturnDatatable(commandString);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
listcntrycode.DataContext = ds;
}