0
一直試圖弄清楚,我如何捕獲列表框中的事件。在模板中,我添加了參數IsChecked =「」,它啓動了我的方法。但是,問題是試圖捕獲方法中檢查的內容。 SelectedItem只返回當前選中的內容,而不是複選框。捕獲WPF Listbox複選框選擇
object selected = thelistbox.SelectedItem;
DataRow row = ((DataRowView)selected).Row;
string teststring = row.ItemArray[0].ToString(); // Doesn't return the checkbox!
<ListBox IsSynchronizedWithCurrentItem="True" Name="thelistbox" ItemsSource="{Binding mybinding}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<CheckBox Content="{Binding personname}" Checked="CheckBox_Checked" Name="thecheckbox"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
感謝這個!最後一種方法效果很好。想到使用你所描述的第二種方式,但是我的UI仍處於不斷變化的狀態。 – wonea 2010-05-17 09:11:16