In WPF / XAML, how do I resize a paragraph of text using a scrollbar?

I am new to WPF / XAML and now I am just learning.

I have a nod and I want to resize the text in the tag depending on the position of the scroll bar.

Text is defined by this code:

<FlowDocumentScrollViewer Grid.Row="1"> <FlowDocument> <Paragraph> Text goes here </Paragraph> </FlowDocument> </FlowDocumentScrollViewer> 

I am trying to define a Setter, and I got to this:

 <Style TargetType="{x:Type Paragraph}"> <Setter Property="FontSize" Value="???" /> </Style> 

But I can’t find out what needs to be done in place of β€œ???”. I tried Google to answer this question, but I think I should use the wrong search terms because I haven't found the answer yet.

I suppose this will be really obvious, but I must admit that I'm at a standstill.

0
source share
3 answers

You can simply set the font size using the binding expression as follows:

 <Paragraph FontSize="{Binding ElementName=scroll1, Path=Value}" /> <ScrollBar x:Name="scroll1"></ScrollBar> 

What you want to learn is the syntax of the binding expression, since intellisense is not currently supported there.

+1
source

The code I implemented is as follows:

 <Style TargetType="{x:Type Paragraph}"> <Setter Property="FontSize" Value="{Binding ElementName=FontSizeScroll, Path=Value}" /> </Style> 

What works.

+1
source

The FontSize value is just a number that describes the size (at the points I think):

 <Style TargetType="{x:Type Paragraph}"> <Setter Property="FontSize" Value="12"/> </Style> 

I do not know if this is your answer, because it is really obvious.

0
source

All Articles