Closed alexrp closed 4 years ago
The default theme for MardownViewer
has a control template with FlowDocumentScrollViewer
setting the vertical scrollbar visibility to Auto
. You can override it by providing your own template.
Taking by example the MainWindow.xaml
from the sample project (some lines omitted for clarity):
<Window x:Class="Markdig.Wpf.SampleApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:markdig="clr-namespace:Markdig.Wpf;assembly=Markdig.Wpf">
<FrameworkElement.Resources>
<Style TargetType="markdig:MarkdownViewer">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="markdig:MarkdownViewer">
<FlowDocumentScrollViewer Document="{TemplateBinding Document}"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</FrameworkElement.Resources>
<DockPanel>
<markdig:MarkdownViewer x:Name="Viewer"/>
</DockPanel>
</Window>
That worked, thanks!
With a
RichTextBox
, you can changeHorizontalScrollBarVisibility
/VerticalScrollBarVisibility
to customize the scroll bar's visibility. It doesn't appear that there's an equivalent onMarkdownViewer
.