インターネット全体を検索しましたが、テーブルの列をコンテンツの幅に合わせて拡大する簡単な解決策と、テーブルを画面の中央に集中させる方法が見つかりません。常に左揃えです。やってみ<TableColumn width="Auto">
ました。それはトリックをしませんでした。唯一うまくいったのは<TableColumn width="200">
. 列をコンテンツの幅に合わせて拡大するにはどうすればよいですか? また、テーブルを画面の中央に配置するにはどうすればよいですか? または、グリッドオプションに頼るべきですか?
ここに私のXAMLがあります:
<src:BaseSurveyElement x:Class="Question14"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:DAQExperiment"
Title="Question14" FontStyle="Normal" FontSize="20" WindowState="Maximized" >
<Grid Height="600" Width="1100">
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<!-- <FlowDocumentReader Grid.Row="0" Name="FlowDocReader" Margin="2 2 2 2" ViewingMode="Scroll"/> -->
<TextBlock Name="txtBlock" Grid.Row="0" Margin="20" TextWrapping="Wrap" />
<!--<ScrollViewer Height="500" Width="1100" Grid.Row="1"
VerticalScrollBarVisibility="Visible" CanContentScroll="True">-->
<FlowDocumentReader Grid.Row="1" UseLayoutRounding="True" SnapsToDevicePixels="True" Width="1200">
<FlowDocumentReader.Resources>
<Style TargetType="TableCell">
<Setter Property="TextAlignment" Value="Center"/>
</Style>
</FlowDocumentReader.Resources>
<FlowDocument >
<Table CellSpacing="0" TextAlignment="Justify" >
<Table.Columns >
<TableColumn />
<TableColumn />
<TableColumn />
<TableColumn />
<TableColumn />
<TableColumn />
</Table.Columns>
<TableRowGroup Paragraph.TextAlignment="Center" >
<TableRow>
<TableCell BorderBrush="Black" BorderThickness="1">
<Paragraph FontWeight="Bold"></Paragraph>
</TableCell>
<TableCell BorderBrush="Black" ColumnSpan="2" BorderThickness="0,1,1,1">
<Paragraph FontWeight="Bold">Option A</Paragraph>
</TableCell>
<TableCell BorderBrush="Black" ColumnSpan="2" BorderThickness="0,1,1,1">
<Paragraph FontWeight="Bold">Option B</Paragraph>
</TableCell>
<TableCell BorderBrush="Black" BorderThickness="0,1,1,1">
</TableCell>
</TableRow>
<TableRow>
<TableCell BorderBrush="Black" BorderThickness="1,0,1,1">
<Paragraph FontWeight="Bold">Subscription</Paragraph>
</TableCell>
<TableCell BorderBrush="Black" BorderThickness="0,0,1,1">
<Paragraph>Monthly</Paragraph>
</TableCell>
<TableCell BorderBrush="Black" BorderThickness="0,0,1,1">
<Paragraph>Yearly</Paragraph>
</TableCell>
<TableCell BorderBrush="Black" BorderThickness="0,0,1,1">
<Paragraph>Monthly</Paragraph>
</TableCell>
<TableCell BorderBrush="Black" BorderThickness="0,0,1,1">
<Paragraph>Monthly</Paragraph>
</TableCell>
<TableCell BorderBrush="Black" BorderThickness="0,0,1,1">
<Paragraph>
<StackPanel Orientation="Vertical" Margin="10,5,10,10" Name="spl1RdBtn">
<RadioButton GroupName="rbtngrp1" Content="Choice A" Margin="0,0,20,0" Name="rbtn1A" />
<RadioButton GroupName="rbtngrp1" Content="Choice B" Margin="0,0,20,0" Name="rbtn1B" />
</StackPanel>
</Paragraph>
</TableCell>
</TableRow>
<TableRow>
<TableCell BorderBrush="Black" BorderThickness="1,0,1,1" TextAlignment="Center">
<Paragraph FontWeight="Bold">Price</Paragraph>
</TableCell>
<TableCell BorderBrush="Black" BorderThickness="0,0,1,1">
<Paragraph>$120.00</Paragraph>
</TableCell>
<TableCell BorderBrush="Black" BorderThickness="0,0,1,1">
<Paragraph>$1000.00</Paragraph>
</TableCell>
<TableCell BorderBrush="Black" BorderThickness="0,0,1,1">
<Paragraph>$130.00</Paragraph>
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
</FlowDocument>
</FlowDocumentReader>
<!--</ScrollViewer>-->
</Grid>
<Window.Background>
<LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
<GradientStop Color="Gray" Offset="0" />
<GradientStop Color="White" Offset="1" />
</LinearGradientBrush>
</Window.Background>
そして、これが私が結果として得たものです: