列表框的图片如下:如何从WPF列表框中选中的单选按钮中选中的列表项
Listbox with Dynamic column with check boxes and static radio buttons
我要寻找从列表框中选择的项目和选定的单选按钮每个选择的项目
<ListBox Height="226" HorizontalAlignment="Left" Margin="404,339,0,0" Name="listBoxItems" VerticalAlignment="Top" Width="282" SelectionChanged="listBoxItems_SelectionChanged" SelectionMode="Multiple">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="10,5,0,0">
<CheckBox Width="130" x:Name="chbPrescr" Content="{Binding}" IsChecked="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Path=IsSelected}">
<!--<TextBlock Text="{Binding}" Width="115"></TextBlock>-->
</CheckBox>
<RadioButton x:Name="rdOD" Width="40" Content ="OD" Checked="rdOD_Checked" />
<RadioButton x:Name="rdBD" Width="40" Content ="BD" Checked="rdBD_Checked"/>
<RadioButton x:Name="rdTDS" Width="40" Content ="TDS" Checked="rdTDS_Checked"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
,并在回发事件我得到选中的列表项,但不是选定的单选按钮为选中的列表项
foreach (var items in listBoxItems.SelectedItems)
{
string a = items.ToString();
ItemCollection itemCollection = listBoxItems.Items;
object currentItem = itemCollection.CurrentItem;
}
我需要知道如何获得每种选定药物的类别。由于
你已经在使用一些具有约束力。为什么不绑定单选按钮?然后你的viewmodels中有值。 –