0

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)

madan
  • 773
  • 13
  • 38
  • 1
    "but not find an expected result", what does that mean? Did the text segment appear in bold font or not? – Clemens Nov 26 '14 at 13:18
  • Thanks for reply . ya it appears as bold.So you mean to say and are same for wpf – madan Nov 26 '14 at 13:27
  • `b` and `strong` are the same in HTML as well, `b` is legacy mark-up that breaks the separation of structure and presentation and `strong` bears semantic meaning, it is not primarily stylistic device. I can't comment on the difference of font-weight and font-stretch in wPF, thought, hopefully someone chimes in with an explanation for curious. – Tomáš Hübelbauer Nov 26 '14 at 13:48
  • Could it be that `stretch` is computed while `weight` is defined in the font file similarly like (if I'm not mistaken) `oblique` is computed geometrically while `italic` is defined in the font file by the designer? – Tomáš Hübelbauer Nov 26 '14 at 13:51

1 Answers1

0

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>
toadflakz
  • 7,764
  • 1
  • 27
  • 40
  • thanks for your answer. it may looks like same but for me the length of the text(means in pixel) meters – madan Nov 27 '14 at 04:10