私はこれを投稿しているので、コードを誰でも利用できるようにしています。一度に1文字ずつTextBlockにテキストを追加
Noctisの提案に基づいてわずかに減少したコード。
StringBuilder DescriptionText = new StringBuilder();
async void RunDescription(StringBuilder description)
{
DescriptionText = description;
await Task.Delay(1000); // Short delay before the text starts printing so the window has time to load
new Thread(AddTextToTextBlock).Start();
}
void TextBlockDispatcher(string text)
{
TextBlock1.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => TextBlock1.Inlines.Add(text)));
}
void AddTextToTextBlock()
{
foreach (char c in DescriptionText.ToString())
{
Thread.Sleep(30);
TextBlockDispatcher(c.ToString());
}
}
誰かが見直して提案したい作業コードは、codereview.stackexchange.comに属します。そこにさえ、あなたが解説したいと思う側面をはっきりと示している良い[mcve]を提供する必要があります。スタックオーバーフローは、特定の、実用的な_problems_コードです。 –
codereview.stackexchange.comに属しているので、この質問を議論の対象外とすることにしました。 – Jeff
@PeterDunihoありがとうございます。 – Cusha