Skip to content
This repository was archived by the owner on Mar 14, 2024. It is now read-only.
This repository was archived by the owner on Mar 14, 2024. It is now read-only.

[Assistance Request] AutoLinks and Images Not Working #10

@amkuchta

Description

@amkuchta

Issue

First off, let me start by saying that from what I can see in the sample app, this control is amazing - literally exactly what I need.

I am having some issues with getting my markdown to render correctly - I am using databindings to display the information, so I don't know if that is the culprit or not. The markdown itself displays, and some of the extensions work (e.g. pipe tables), but not all of them. Specifically:

For posterity, my code snippets are below:

View

The Markdown property is bound to the Contents value (typeof string) of the SelectedItem of a list in another control; Pipeline is bound to a MarkdownPipeline that is created in the ViewModel. As stated above, the Contents renders in the MarkdownViewer, just without some extensions working properly.

<wpf:MarkdownViewer 
      Markdown="{Binding ElementName=userGuidePagesListView, Path=SelectedItem.Contents}"
      Pipeline="{Binding MarkdownPipeline}" />

ViewModel

The Contents property is set by extracting the data from embedded resources files to a string

public class UserGuideViewModel : ViewModelBase
{
  public MarkdownPipeline MarkdownPipeline = new MarkdownPipelineBuilder()
      .UseAdvancedExtensions()
      .UseEmphasisExtras()
      .UseAutoLinks()
      .UseEmojiAndSmiley()
      .Build();

  private List<UserGuidePage> _userGuidePages = new List<UserGuidePage>();
  public List<UserGuidePage> UserGuidePages
  {
    get { return _userGuidePages; }
    set
    {
      if (_userGuidePages != value)
      {
        _userGuidePages = value;
        RaisePropertyChanged("UserGuidePages");
      }
    }
  }

  public UserGuideViewModel()
  { RenderUserGuidePages(); }

  private void RenderUserGuidePages()
  {
    UserGuidePages = new List<UserGuidePage>();
    string[] delimiter = new string[] { "UserGuide." };
    string[] markdownFiles = assembly.GetManifestResourceNames();
    foreach (string resource in markdownFiles)
      {
        if (resource.Contains("UserGuide") && resource.Contains(".md"))
        {
          UserGuidePage userGuidePage = new UserGuidePage();
          userGuidePage.Title = resource.Split(delimiter, StringSplitOptions.None)[1].Split('.')[0].Replace("-", " ");
          userGuidePage.Contents = GetPageContent(resource);
          UserGuidePages.Add(userGuidePage);
        }
      }
    }
  }

  private string GetPageContent(string resource)
  {
    using (Stream stream = assembly.GetManifestResourceStream(resource))
    {
      using (StreamReader streamReader = new StreamReader(stream))
      { return streamReader.ReadToEnd(); }
    }
  }

Screenshots (Annotated)

Screenshots below; I am also using the same markdown files for the Wiki on GitHub, and have included the links to those pages so that proper rendering can be viewed

Home

Using the Software

Change Log

Thank you in advance for the help!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions