从来就只是创建了这样一个ListBox一个DataTemplate:获取一个DataTemplate(WPF)的内部,从文本框中的值
<ListBox Height="150" MinHeight="100" HorizontalAlignment="Left" Name="myListBox"
VerticalAlignment="Top" Width="290"
ItemsSource="{Binding}" SelectionMode="Multiple" Margin="0,18,0,0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" >
<StackPanel Orientation="Horizontal">
<CheckBox Name="cbLista" Width="100" Content="{Binding Path=Nom_estudio}" IsChecked="{Binding IsChecked, Mode=TwoWay}"
Checked="cbLista_Checked" />
<TextBox Name="txbCantidad" Width="100" Margin="0,0,0,5" TextChanged="txbCantidad_TextChanged" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
现在我可以在复选框都被选择的每一个对象,但怎么也我获得每个复选框关联的texbox的文本属性?
您可以使用绑定,例如, 'Text =“{Binding Cantidad}”'。当然,这要求你在具有'Nom_estudio'属性的同一个对象上创建'Cantidad'属性。 –