Survey (string Description, List<Questions> Questions, QuestionTypes Type)
Question (string Description, List<Choice> Choices)
Choice (string Description)
enum QuestionTypes {MultipleChoicesOneAnswer, MultipleChoicesMultipleAnswers}
在列表框中,我想在每个问题的边框中显示每个问题以及每个问题的可用选项。像这样:
[] 21
[ ] 23
[ ] 24
我正在使用以下模板:
<DataTemplate x:Key="MultipleChoicesOneAnswerTemplate" DataType="{x:Type local:Choice}">
<RadioButton Content="{Binding Description}" Foreground="Blue" />
</DataTemplate>
<DataTemplate x:Key="QuestionTemplate" DataType="{x:Type local:Question}">
<DockPanel>
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
<TextBlock Text="{Binding SortingIndex}" />
<TextBlock Text=")" />
<TextBlock Text="{Binding Description}" Margin="5,0,0,0"/>
</StackPanel>
<ListBox ItemTemplate="{StaticResource MultipleChoicesOneAnswerTemplate}" ItemsSource="{Binding Choices}"/>
</DockPanel>
</DataTemplate>
1.如何使模板生成的单选按钮相互排斥?
2.我将如何将用户选择的选项录制到我的模型中?
非常感谢你的帮助。
根据csunwold的建议,它通过使用GroupName工作,但感觉有点像黑客,因为我必须在吐出描述的问题类上重写ToString(),并执行GroupName=“{Binding Question}”。
还有人有什么建议吗?