richtextbox를 사용하여 Windows Phone 7.1에서 일부 Html 컨텐츠를 보여줍니다. windows에서 richtextbox의 사용에 관한 것들
Paragraph1</p>
<img src="http://www.ifanr.com/wp-content/uploads/2011/11/DSC_332401.jpg" alt="" width="600" height="338" /></p>
Paragraph2。</p>
<h3>Title h3</h3>
Paragraph3。
</p>
그럼 내가 배열로 분할하는
"string[] sArray = Regex.Split(html, "</p>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);"
를 사용
HTML 소스 코드는 같다. 마지막으로, 나는이 코드를 사용
foreach (string array in sArray)
{
Paragraph parag = new Paragraph();
Run run = new Run();
Bold bold = new Bold();
if (!Regex.IsMatch(array.ToString(), @"<img\b[^<>]*?\bsrc\s*=\s*[""']?\s*(?<imgUrl>[^\s""'<>]*)[^<>]*?/?\s*>"))
{
//h3
if (array.ToString().Contains("</h3>"))
{
string hString = array.ToString();
hString = Regex.Replace(hString, "<h3>", "");
string[] hArray = Regex.Split(hString, "</h3>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
bold.Inlines.Add(hArray[0].ToString());
parag.Inlines.Add(bold);
run.Text = hArray[1].ToString();
parag.Inlines.Add(run);
}
else
{
if(array.ToString().Contains("<blockquote>"))
{
run.Text = Regex.Replace(array.ToString(), "<blockquote>", "blockquote:");
run.FontSize = 18;
}
else
run.Text = array.ToString();
parag.Inlines.Add(run);
}
rtb.Blocks.Add(parag);
}
else
{
//insert the image into richtextbox
Regex regImg = new Regex(@"http://[^\[^>]*?(gif|jpg|png|jpeg|bmp|bmp)", RegexOptions.IgnoreCase);
MatchCollection matches = regImg.Matches(array.ToString());
string result = null;
foreach (Match match in matches)
result = match.Value;
Image image = new Image();
image.Stretch = Stretch.Uniform;
image.Source = new BitmapImage(new Uri(result, UriKind.RelativeOrAbsolute));
InlineUIContainer iuc = new InlineUIContainer();
iuc.Child = image;
parag.Inlines.Add(iuc);
rtb.Blocks.Add(parag);
}
이를 RichTextBox에 일부 단락 또는 이미지를 추가하기를, 모든 것이 처음에 잘 어울리는,하지만 난하여 RichTextBox를 아래로 스크롤 할 때, 나머지 단락이 사라집니다. 내가 하루 종일 혼란스러워했는데, 나는 richtextbox에 무엇이 잘못되었는지를 알 수 없었습니다. Windows 전화의 버그입니까? 이견있는 사람?
ScreenShot1 :
ScreenShot2 :
추신 : HTML 소스 코드가 일부 비 영어 문자를 포함할지 여부는 중요하지 않습니다 아니. 이것은 HTML 소스 코드가 많은 양의 단어에있을 때 발생합니다. 이 두 스크린 샷은 문제를 보여줍니다.
당신은 영어 문자를 사용하여 코드를 예시한다. 문자로 인해 코드를 읽을 수 있다면 당신을 도울 수 없습니다. – Rego
오키, 잠깐만 ~ – ellic