gpt4 book ai didi

wpf - 在 WPF 中创建一个简单的表?

转载 作者:行者123 更新时间:2023-12-04 12:48:34 24 4
gpt4 key购买 nike

我想知道是否有一种方法(任何组件/控件)可以让我在我的应用程序窗口中绘制一个简单的 Microsoft Word 样式表。像这样的东西:

Sample Table

有任何想法吗?

最佳答案

这取决于您想如何使用它。使用 ItemsControl 之一(如 DataGridListView 等),直接用 Grid 来做面板(如其他答案所推荐)或使用 FlowDocumentFlowDocument允许您指定表、行和列。您还可以一次选择多个单元格进行复制/粘贴等。

enter image description here

<FlowDocumentReader UseLayoutRounding="True" SnapsToDevicePixels="True">
<FlowDocumentReader.Resources>
<Style TargetType="TableCell">
<Setter Property="TextAlignment" Value="Center"/>
</Style>
</FlowDocumentReader.Resources>
<FlowDocument>
<Table CellSpacing="0">
<Table.Columns>
<TableColumn/>
<TableColumn/>
<TableColumn/>
<TableColumn/>
</Table.Columns>
<TableRowGroup>
<TableRow>
<TableCell BorderBrush="Black" BorderThickness="1">
<Paragraph FontWeight="Bold">Category</Paragraph>
</TableCell>
<TableCell BorderBrush="Black" BorderThickness="0,1,1,1">
<Paragraph FontWeight="Bold">A</Paragraph>
</TableCell>
<TableCell BorderBrush="Black" BorderThickness="0,1,1,1">
<Paragraph FontWeight="Bold">B</Paragraph>
</TableCell>
<TableCell BorderBrush="Black" BorderThickness="0,1,1,1">
<Paragraph FontWeight="Bold">C</Paragraph>
</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>
</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>

此页面充满了有关此的有用示例: FlowDocument with Table

关于wpf - 在 WPF 中创建一个简单的表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7385163/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com