Comments (6)
Has a code which access Document property been tried here?
The initial value of Document property is null for now. And this vlaue is not changed until the Source or Markdown property value is changed.
MarkdownScrollViewer inherits from FlowDocumentScrollViewer. So the Document property can be initialized.
markdown.Document = new FlowDocument(new Paragraph(new Run("some text")));
Be careful not to change the Markdown and Source properties. These properties will update Document property.
from mdxaml.
Yes, It was old code from when using RichTextBox.
Maybe make Document setter private? initially being null before Markdown or Source can lead to mistakes like this.
from mdxaml.
The private access level prevents access to Document property.
I plan to change the Document getter so that it does not return null (it is automatically initialized).
public class MarkdownScrollViewer : FlowDocumentScrollViewer, IUriContext
{
・・・
public new FlowDocument? Document
{
get
{
var bs = (FlowDocumentScrollViewer)this;
return bs.Document ??= new FlowDocument();
}
set => ((FlowDocumentScrollViewer)this).Document = value;
}
}
This is not an override, but hides accessible base property.
So if MarkdownScrollViewer is cast to FlowDocumentScrollViewer, the problem recurs.
var viewer1= new MarkdownScrollViewer();
viewer1.Document.Blocks.Add(...); // No error occurres.
var viewer2 = (FlowDocumentScrollViewer)new MarkdownScrollViewer();
viewer2.Document.Blocks.Add(...); // NullReferenceException occures
Would this amendment help you?
from mdxaml.
I think this is fine.
from mdxaml.
v1.17.0 has be released.
The Document does not return null (it is automatically initialized).
from mdxaml.
Great, I'll close this 🥳
from mdxaml.
Related Issues (20)
- Bolding first word in unordered list not rendering correctly HOT 3
- Is there a way to turn off specific list markers (question) HOT 3
- Table of contents or links to anchors HOT 2
- How to Copy code from code block in md ? HOT 1
- Image Scaling and Gif support HOT 1
- Spoilers support (details) HOT 7
- Different code styles HOT 4
- scroll-wheel-hijack HOT 1
- Open Hyper Link crashes when no web browser is installed HOT 1
- Extension point for code highligting
- Aligning headers?
- [Question] Is there a easy way to activate smooth scrolling ?
- Escape character \ not working correctly
- Navigating to another markdown file, and anchors HOT 2
- [Question] Is there any way to adjust the width of columns in a table?
- Memory Leak in MarkdownScrollViewer HOT 1
- MdXaml 1.24.0 depends on AvalonEdit (>= 6.3.0) but AvalonEdit 6.3.0 was not found. An approximate best match of AvalonEdit 6.3.0.90 was resolved.
- image question.
- Many styles are not fully rendered
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mdxaml.