public SamplePage() { InitializeComponent(); HideStatusBar(); // Get selected sample and set that as the DataContext. DataContext = SampleManager.Current.SelectedSample; // Load and show the sample. SampleContainer.Content = SampleManager.Current.SampleToControl(SampleManager.Current.SelectedSample); // Default to the live sample view. LiveSample.IsChecked = true; string folderPath = SampleManager.Current.SelectedSample.Path; string cssPath = "ms-appx-web:///Resources\\github-markdown.css"; string basePath = $"ms-appx-web:///{folderPath.Substring(folderPath.LastIndexOf("Samples"))}"; string readmePath = System.IO.Path.Combine(folderPath, "Readme.md"); string readmeContent = System.IO.File.ReadAllText(readmePath); readmeContent = _markdownRenderer.Parse(readmeContent); readmeContent = readmeContent.Replace("src='", "src=\"").Replace(".jpg'", ".jpg\"").Replace("src=\"", $"src=\"{basePath}\\"); string htmlString = "<!doctype html><head><link rel=\"stylesheet\" href=\"" + cssPath + "\" /></head><body class=\"markdown-body\">" + readmeContent + "</body>"; DescriptionView.NavigateToString(htmlString); SourceCodeContainer.LoadSourceCode(); }
public void SetSample(SampleInfo sample) { DataContext = sample; string folderPath = sample.Path; string readmePath = System.IO.Path.Combine(folderPath, "Readme.md"); string readmeContent = System.IO.File.ReadAllText(readmePath); string cssPath = folderPath.Substring(0, folderPath.LastIndexOf("Samples")) + "Resources\\github-markdown.css"; readmeContent = _markdownRenderer.Parse(readmeContent); string htmlString = "<!doctype html><head><base href=\"" + readmePath + "\"><link rel=\"stylesheet\" href=\"" + cssPath + "\" /></head><body class=\"markdown-body\">" + readmeContent + "</body>"; DescriptionView.NavigateToString(htmlString); }