I've been trying to make a user control for a questionaire application where I have some questions that needs follow-up questions under certain conditions. A simple senario could be that we want to show follow-up quesions if we get a "yes" on some question.
At this point I have followed the example from Zenexer on a similar question. My thought was that I would put the first child of my user control in one container (a StackPanel
or whatever) and all
subsequent elements in a second StackPanel
. But in the aforementioned example all child elements get stuffed into one element in the user control. To my understanding this is because [ContentProperty(nameof(Children))]
is set to all of the content of the user control.
I tried to change the getter and setter of Children
in the Zenexer's example but to no avail.
The Question: Is there a way to spilt the children of my user control into two (or more) elements in my user control with XAML that looks something like this:
MainWindow.xaml
<SubQuestionBox>
<BinaryQuestion
QuestionNumber="4.1"
QuestionText="Parent question"/>
<TextQuestion
QuestionNumber="4.1.1"
QuestionText="Child question 1"/>
<TextQuestion
QuestionNumber="4.1.2"
QuestionText="Child question 2"/>
</SubQuestionBox>
SubQuestionBox.xaml
<UserControl x:Class="SubQuestionBox">
<!--StackPanel To contain the question controls-->
<StackPanel>
<StackPanel x:Name="ParentContainer" />
<StackPanel x:Name="SubQuestionsContainer" />
</StackPanel>
</UserControl>