【发布时间】:2011-02-11 07:46:02
【问题描述】:
请查看我正在使用的 ListBox 的代码
<ListBox Name="listBoxDefaultAcc" HorizontalAlignment="Left" VerticalAlignment="Top" Width="450" Height="410">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Height="60" Width="450">
<RadioButton Content="{Binding}" GroupName="defaultAcc" HorizontalAlignment="Left" VerticalAlignment="Center" Height="80" Width="450" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
现在我想从代码隐藏中访问RadioButton 的content 属性。
ListBoxItems 正在使用以下代码从代码隐藏中动态填充:
listBoxDefaultAcc.ItemsSource = from acc in db.Table<Accounts>()
select acc.accName;
请帮帮我。
【问题讨论】:
-
您想在什么时候访问它以及为哪个
RadioButton?附带说明,我不认为ListBoxItem可以使用 ItemTemplate 选择 -
我想获取选定的
RadioButton的内容并将其存储在隔离存储中,如果此ItemTemplate没有帮助,那么您能否建议我正确的方法。这是使用上述代码生成的 GUI 屏幕截图。 link
标签: c# silverlight windows-phone-7 listboxitem