1
如何使用C#
我這樣做是爲Windows Phone應用程序,以獲取RichTextBox的文本在Windows Phone應用程序文本塊如何將richtextbox文本轉換爲windows phone應用程序中的文本塊?
private void OnMessageReceived(string message)
{
var paragraph = new Paragraph();
var runs = new List<Inline>();
foreach (var word in message.Split(' '))
{
Uri uri;
if (Uri.TryCreate(word, UriKind.Absolute, out uri) ||
(word.StartsWith("www.") || word.EndsWith(".com") || word.Contains("@") && Uri.TryCreate("http://" + word, UriKind.Absolute, out uri)))
{
var link = new Hyperlink();
link.Inlines.Add(new Run() { Text = word });
link.Click += (sender, e) =>
{
var hyperLink = (sender as Hyperlink);
new WebBrowserTask() { Uri = uri }.Show();
};
runs.Add(link);
}
else
{
runs.Add(new Run() { Text = word });
}
runs.Add(new Run() { Text = " " });
}
foreach (var run in runs)
paragraph.Inlines.Add(run);
txtDisplayText.Blocks.Add(paragraph);
}
「txtDiplayText」 是一個RichTextBox 我想,RichTextBox的數據TextBlock的
enter code here