Skip to content

Commit

Permalink
Made DisabledLazyLoad for Markdown Engine accessible from MarkdownScr…
Browse files Browse the repository at this point in the history
…ollViewer to allow the use of our own dispatcher.
  • Loading branch information
boelew committed Jan 17, 2024
1 parent d58819c commit 5312892
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions MdXaml/MarkdownScrollViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public class MarkdownScrollViewer : FlowDocumentScrollViewer, IUriContext

public static readonly DependencyProperty MarkdownStyleNameProperty =
DependencyProperty.Register(
nameof(MarkdownStyleName),
typeof(string),
typeof(MarkdownScrollViewer),
new PropertyMetadata(nameof(MdStyle.Standard), UpdateStyleName));
nameof(MarkdownStyleName),
typeof(string),
typeof(MarkdownScrollViewer),
new PropertyMetadata(nameof(MdStyle.Standard), UpdateStyleName));

public static readonly DependencyProperty AssetPathRootProperty =
DependencyProperty.Register(
Expand All @@ -71,6 +71,13 @@ public class MarkdownScrollViewer : FlowDocumentScrollViewer, IUriContext
typeof(MarkdownScrollViewer),
new PropertyMetadata(null, UpdateAssetPathRoot));

public static readonly DependencyProperty DisabledLazyLoadProperty =
DependencyProperty.Register(
nameof(DisabledLazyLoad),
typeof(bool),
typeof(MarkdownScrollViewer),
new PropertyMetadata(false, UpdateDisabledLazyLoad));


private static void UpdateSource(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
Expand Down Expand Up @@ -163,6 +170,18 @@ private static void UpdateAssetPathRoot(DependencyObject d, DependencyPropertyCh
}
}

private static void UpdateDisabledLazyLoad(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if(d is MarkdownScrollViewer owner)
{
var disabledLazyLoad = (bool)e.NewValue;
if (disabledLazyLoad != owner.Engine.DisabledLazyLoad)
{
owner.Engine.DisabledLazyLoad = (bool)e.NewValue;
}
}
}

private string _fragment;
private Uri _source;

Expand Down Expand Up @@ -305,6 +324,12 @@ public string MarkdownStyleName
set { SetValue(MarkdownStyleNameProperty, value); }
}

public bool DisabledLazyLoad
{
get { return (bool)GetValue(DisabledLazyLoadProperty); }
set { SetValue(DisabledLazyLoadProperty, value); }
}

public Uri? Source
{
get { return (Uri)GetValue(SourceProperty); }
Expand Down

0 comments on commit 5312892

Please sign in to comment.