ToolTip の Binding で StringFormat を使う方法
ToolTip の Binding で StringFormat は無効なようです。使おうとして↓のように書いても at の文字は表示されません。StringFormat は無視され、Hoge の数だけが表示されます。
<TextBlock Text="{Binding Value, StringFormat={}{0:N0}}" ToolTip="{Binding Hoge, StringFormat={}at {0:N0}}" />
StringFormat の代わりに ContentStringFormat を使って↓のように書くと期待通りに表示されます。
<TextBlock Text="{Binding Value, StringFormat={}{0:N0}}"> <TextBlock.ToolTip> <ToolTip Content="{Binding Hoge}" ContentStringFormat="{}at {0:N0}" /> </TextBlock.ToolTip> </TextBlock>
# いちいち面倒ですよねぇ。DSL は変なこだわりを捨てて便利さを追求するべき!
関連:
- Binding の StringFormat のスニペット