-
Notifications
You must be signed in to change notification settings - Fork 37
How to access ScrollViewer
whistyun edited this page Dec 16, 2022
·
1 revision
MarkdownScrollViewer
extends FlowDocumentScrollViewer
which has no properties to access ScrollViewer
.
To access ScrollViewer
, We should walk a visual tree.
a viewclass containing MarkdownScrollViewer
:
// MarkdownScrollViewer MdScrlViewer;
public ScrollViewer ScrollViewer
{
get
{
DependencyObject obj = MdScrlViewer;
do
{
if (VisualTreeHelper.GetChildrenCount(obj) > 0)
obj = VisualTreeHelper.GetChild(obj as Visual, 0);
else
return null;
}
while (!(obj is ScrollViewer));
return obj as ScrollViewer;
}
}
Click here for sample projects.
MainWindow.xaml
and MainWindow.xaml.cs
is the view containing MarkdownScrollViewer
.