3
3

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.

StringFormat内で書式指定子をそのまま出す

Last updated at Posted at 2013-04-26
Xaml
<TextBlock Text="{Binding MeetingDate, StringFormat='次のPM会議は yyyy/MM/dd です'}" />

みたいな XAML を書いたら以下のようになりました。

「次のP4会議は 2013/04/25 です」

P4 て何。文字化け?と一瞬わからなかったけど、遅れて気付いた。
Monthly で置換されている…!

なるほど、エスケープが必要らしい。

書式指定子をそのまま出すにはどうするんだっけ…
ああクォーテーションで囲ってやれば良いのか。

ちなみに StringFormat 全体をシングルクォートで囲っている場合は ' と書くと怒られました。
その場合は &quot; なら良いようです。(←これでまたちょっと躓いた)

Xaml
<TextBlock Text="{Binding MeetingDate, StringFormat='&quot;次のPM会議は&quot; yyyy/MM/dd です'}" />


<TextBlock Text="{Binding MeetingDate, StringFormat=\'次のPM会議は\' yyyy/MM/dd です}" />

ちゃんと出た。ふう。

3
3
0

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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?