mardi 17 janvier 2017

Using XAML markup and binding, how would I display a list of items and list of subitems under each item?

I have a list of questions in an array and each question type has a list of answers which is a list of strings. I need to display each question and under each question the answers assigned to the question with a CheckBox for each answer. I have the questions displaying on the form, but have not been able to get the answers up. Below is what I have for markup binding the questions only:

<ItemsControl x:Name="IcQuestions">
    <ItemsControl.ItemTemplate>
        <DataTemplate DataType="questions:QuestionAnswers">
            <StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Question Type" HorizontalAlignment="Stretch" Width="Auto" Margin="0,10,5,0" FontWeight="Bold"></TextBlock>
                    <TextBlock TextWrapping="WrapWithOverflow" Text="{Binding QuestionType}" HorizontalAlignment="Stretch" Width="Auto" Margin="0,10,0,0" FontWeight="Bold"></TextBlock>
                </StackPanel>
                <TextBlock TextWrapping="WrapWithOverflow" Text="{Binding Question}" HorizontalAlignment="Stretch" Width="Auto" Margin="0,0,0,0" FontWeight="Bold"></TextBlock>
            </StackPanel>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>




Aucun commentaire:

Enregistrer un commentaire