例如,我想要一个绑定到observableCollection的文本块列表如下:
乙 CF
乙 OY
B OOK
一个的乙 SOR的乙
乙 EFORE
答案 0 :(得分:0)
您可以在C#中使用Flow document,使用FlowDocument.FontWeight
<FlowDocumentReader>
<FlowDocument
FontFamily="Century Gothic"
FontSize="12"
FontStretch="UltraExpanded"
FontStyle="Italic"
FontWeight="UltraBold"
>
<Paragraph>
Any font settings on this paragraph would override the font settings
for the FlowDocument.
</Paragraph>
</FlowDocument>
</FlowDocumentReader>
FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run("A bit of text content...")));
// Set the desired column gap to 10 device independend pixels.
flowDoc.FontFamily = new FontFamily("Century Gothic");
flowDoc.FontSize = 12.0;
flowDoc.FontStretch = FontStretches.UltraExpanded;
flowDoc.FontStyle = FontStyles.Italic;
flowDoc.FontWeight = FontWeights.UltraBold;
另一种方法是使用运行标记,正如@Gaurang建议的那样:
public SectionExample()
{
// Create three paragraphs
Paragraph myParagraph1 = new Paragraph(new Run("Paragraph 1"));
Paragraph myParagraph2 = new Paragraph(new Run("Paragraph 2"));
Paragraph myParagraph3 = new Paragraph(new Run("Paragraph 3"));
// Create a Section and add the three paragraphs to it.
Section mySection = new Section();
mySection.Background = Brushes.Red;
mySection.Blocks.Add(myParagraph1);
mySection.Blocks.Add(myParagraph2);
mySection.Blocks.Add(myParagraph3);
// Create a FlowDocument and add the section to it.
FlowDocument myFlowDocument = new FlowDocument();
myFlowDocument.Blocks.Add(mySection);
this.Content = myFlowDocument;
}