我想写一份问卷。它将在一个标签中。我想要三列:问题编号,问题,组框。我将有14个,所以一切都必须有自己的行。第2列中的文本有时足够长以包装。我觉得我已经尝试了所有组合,但我要么得到非常大的字体或非常小的字体。我希望能够调整窗口大小。无论我最近做了什么,都会使它垂直调整,但不能横向调整。我非常喜欢初学者,所以我提前为间距道歉。
<Grid>
<Label Name="ADCS" Content="ADCS" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="6" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="270*" />
<ColumnDefinition Width="54*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Viewbox>
<StackPanel HorizontalAlignment="Left" Name="stackPanel2">
<Label Name="a1" Content="1." Grid.Column="1" Grid.Row="1" Margin="6" />
<Label Name="lblADCS1" Grid.Column="2" Grid.Row="1" Margin="6" />
<TextBlock
Text="Do you like cheese?" TextWrapping = "WrapWithOverflow">
</TextBlock>
<GroupBox Header="ADCS1" Grid.Row="1" Grid.Column="3">
<StackPanel Orientation="Horizontal" >
<RadioButton Margin ="5" Name="Yes__1" />
<RadioButton Margin ="5" Name="No__1" />
<RadioButton Margin ="5" Name="Maybe__1" />
<RadioButton Margin ="5" Name="Clear__1" />
</StackPanel>
</GroupBox>
<Label Name="a2" Content="2." Grid.Column="1" Grid.Row="2" Margin="6" />
<Label Name="lblADCS2" Grid.Column="2" Grid.Row="2" Margin="6">
<TextBlock
Text="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua?"
TextWrapping = "WrapWithOverflow">
</TextBlock>
</Label>
<GroupBox Header="ADCS2" Grid.Column="3" Grid.Row="2" >
<StackPanel Orientation="Horizontal" >
<RadioButton Margin ="5" Name="Yes__2" />
<RadioButton Margin ="5" Name="No__2" />
<RadioButton Margin ="5" Name="Maybe__2" />
<RadioButton Margin ="5" Name="Clear__2" />
</StackPanel>
</GroupBox>
</StackPanel>
</Viewbox>
</Grid>
</Grid>
答案 0 :(得分:0)
如果您要针对14个问题执行此操作,我建议使用数据驱动的解决方案。编写一个Question类并将14个Question对象添加到集合中,并将该集合数据绑定到带有一些datatemplate的itemscontrol。
无论如何,下面是一个网格,显示了两个带文字换行的问题。
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Grid.Column="0" Grid.Row="0" Content="1" /> <!--Question Number-->
<TextBlock Grid.Column="1" Grid.Row="0" TextWrapping="WrapWithOverflow" Text="Do you like cheese?" /> <!--Question-->
<GroupBox Header="ADCS1" Grid.Row="0" Grid.Column="2"> <!--Group Box-->
<StackPanel Orientation="Horizontal" >
<RadioButton Content="A" />
<RadioButton Content="B" />
<RadioButton Content="C" />
</StackPanel>
</GroupBox>
<Label Grid.Column="0" Grid.Row="1" Content="1" /> <!--Question Number-->
<TextBlock Grid.Column="1" Grid.Row="1" TextWrapping="WrapWithOverflow" Text="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua?" /> <!--Question-->
<GroupBox Header="ADCS1" Grid.Row="1" Grid.Column="2"> <!--Group Box-->
<StackPanel Orientation="Horizontal" >
<RadioButton Content="A" />
<RadioButton Content="B" />
<RadioButton Content="C" />
</StackPanel>
</GroupBox>
</Grid>
答案 1 :(得分:0)
我改变了你的代码:
看看它是否适合你
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Name="ADCS" Content="ADCS" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="6" />
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<StackPanel HorizontalAlignment="Stretch" Name="stackPanel2" >
<Label Name="a1" Content="1." Margin="6" />
<Label Name="lblADCS1" Margin="6">
<TextBlock
Text="Do you like cheese?" TextWrapping = "WrapWithOverflow">
</TextBlock>
</Label>
<GroupBox Header="ADCS1">
<StackPanel Orientation="Horizontal" >
<RadioButton Margin ="5" Name="Yes__1" />
<RadioButton Margin ="5" Name="No__1" />
<RadioButton Margin ="5" Name="Maybe__1" />
<RadioButton Margin ="5" Name="Clear__1" />
</StackPanel>
</GroupBox>
<Label Name="a2" Content="2." Margin="6" />
<Label Name="lblADCS2" Margin="6">
<TextBlock
Text="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua?"
TextWrapping = "WrapWithOverflow">
</TextBlock>
</Label>
<GroupBox Header="ADCS2" >
<StackPanel Orientation="Horizontal" >
<RadioButton Margin ="5" Name="Yes__2" />
<RadioButton Margin ="5" Name="No__2" />
<RadioButton Margin ="5" Name="Maybe__2" />
<RadioButton Margin ="5" Name="Clear__2" />
</StackPanel>
</GroupBox>
</StackPanel>
</ScrollViewer>
</Grid>
希望这有帮助,尊重