Equivalent of html "<strong>" tag in WPF?

506 views Asked by At

I have html file containing text with strong tag can say <strong>Windows Presentation Framework</strong>. I want to implement strong tag in flow document of WPF. I tried by setting font weight property to bold but not find an expected result/output as in html file. Any clue or hint on how to do it?

For <b> tag i tried with :

flowdocument.FontWeight = FontWeights.Bold;

I am trying to say whether I am go for class FontWeights(Bold or ExtraBold or SemiBold or Normal) or class FontStretches(Expanded or SemiExpanded or ExtraExpanded or Normal)

1

There are 1 answers

1
toadflakz On

Your content should look like this in XAML:

<FlowDocument><Paragraph><Bold>Windows Presentation Foundation</Bold></Paragraph></FlowDocument>

Have a look at the link below for more information on FlowDocument structure - it has it's own markup scheme like HTML (except it's XML): http://msdn.microsoft.com/en-us/library/aa970786(v=vs.110).aspx

Edit: To the downvoters - copy and paste this code into any XAML designer - it is CORRECT! It achieves the same typographic effect as <strong> in HTML.

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Grid>
        <RichTextBox>
            <FlowDocument>
                <Paragraph>
                    <Bold>Windows Presentation Foundation</Bold>
                </Paragraph>
            </FlowDocument>
        </RichTextBox>
    </Grid>
</Window>