3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[WPF][XAML]StyleにTextWrappingのWrap指定をすると表示が遅くなる

Last updated at Posted at 2017-10-26

概要

テキストが大量に入っている要素にTextWrappingのWrapスタイルを適用すると、
表示するまでに時間がかかりフリーズしてしまいます。

環境

  • Windows10
  • Visual Studio Professional 2015

発生条件

  • スタイルにTextWrappingのWrapを指定している
  • テキスト量が多い(19,000文字で発生していますが、どこから重くなるかは未確認)
  • 上記2つの条件を満たした上で折り返しが発生している

対策

根本的な解決方法は発見できていません。
同じ要素に固定幅を指定することで少しは軽くなりましたが、理由はよく分かりませんでした。
指定する数値によっても重さに差が出るため、適用する場合は色々な幅で試すことをオススメします。

その他の対策

こちらが一番スムーズにいきそうな対応策ですが、なるべくXAMLのみで解決できる方法を探していたので試していません。

You could react to the windowResizeStart event and disable wrapping for the >text block. Then wrap just once when the resize completes.

You gain performance but lose some visual flair I guess.

良い方法をご存知の方がいらっしゃれば是非ご教示いただけると嬉しいです!!
改めて表示を確認していたところ、表示速度が改善されていました。
その間Visual Studio 2015から2017へのアップデートを行いましたが、それで解消されたのかは不明です。
再現しなくなってしまったので原因は分からずじまい。。

3
1
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?