Reputation: 29153
I'm trying to find out how to anchor all of the content in a RichTextBox control to a particular location, for example: horizontal = center and vertical = center. I can horizontally align paragraphs, but not all of the content in the control itself (which anchors at top/left by default). It appears, from the documentation that <VerticalContentAlignment>
and <HorizonalContentAlignment>
should be able to be used for this effect, but setting doesn't do anything to the content in the control.
Does anyone know if:
<VerticalContentAlignment>
and
<HorizonalContentAlignment>
do
indeed work, but I'm just not using
them correctly and need to do
something else?Other controls do have this feature, for example the below works fine:
<Button Width="73" Height="76" VerticalContentAlignment="Bottom" HorizontalContentAlignment="Right">hello</Button>
Upvotes: 2
Views: 719
Reputation: 29153
Figured it out. Create a copy of the style and then in the ScrollViewer section, put this:
<ScrollViewer x:Name="ContentElement" BorderThickness="0" IsTabStop="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
Upvotes: 2