2
我在互聯網上搜索,找不到一個簡單的解決方案,以擴展表格列的內容寬度,以及如何集中在屏幕中間的表。它總是與左邊對齊。我試過<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>
這裏是我所得到的結果:
無法設置未知成員'System.Windows.Documents.table.VerticalAlignment'。 – McKay 2015-08-13 18:49:31