I have a stackpanel containing two radio buttons (Option 1 and Option 2). If the user selects Option 2 a textbox should be active that allows the user to give some more details about Option 2.
I came up with two solutions but none of them is exactly what I want. This is how they look like:
Solution #1
The XAML-code of solution #1 is very simple and the result is pretty obvious:
<StackPanel Grid.Row="7" Grid.Column="1">
<RadioButton>Option 1</RadioButton>
<RadioButton>Option 2:</RadioButton>
<TextBox>Some Text that details option 2</TextBox>
</StackPanel>
What's good here is that the textbox uses the entire width. Nevertheless, that's not what I wanted since the textbox should be placed next to the Option 2.
Solution #2
The next step was to create a grid in the RadioButton-tags. That allowed me to place the textbox at the proper position but then the width doesn't scale up to 100 % anymore.
The code looks like this:
<StackPanel Grid.Row="8" Grid.Column="1">
<RadioButton>Option 1</RadioButton>
<RadioButton>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="130*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" >Option 2:</TextBlock>
<TextBox Grid.Column="1" Margin="10,0,0,0">Some Text that details option 2</TextBox>
</Grid>
</RadioButton>
</StackPanel>
Besides the point that this looks to me like a quite over-engineered solution, the question is here: How to set the width of grid within a radio button entry to 100%?
A similar question was asked here (How to set width to 100% in WPF) but using the ItemContainerStyle
property does not work for radiobuttons.
In my eyes, there must be a much easier (or at least a working) solution. Can anyone help?