Why is AccessText not used when using ContentStrin

2019-08-22 12:02发布

When using a string value as Content of a ContentControl (like Label), using an _ inside the string allows using the following letter as access key, like this:

<Label Content="Text with _access key"/>

or even

<Label Content="{Binding Text}"/>

if Text is a string property containing an _.

However, when using ContentStringFormat which contains the _, it doesn't work any more:

<Label Content="{Binding Value}" ContentStringFormat="_Formatted value {0}"/>

I have seen in the debugger that no AccessText is used in this case.

As a workaround, I have used AccessText explicitly:

<Label>
  <AccessText Text="{Binding Value, StringFormat=_Formatted value {0}"/>
</Label>

It works that way but I still want to know why it doesn't when using ContentStringFormat.

1条回答
来,给爷笑一个
2楼-- · 2019-08-22 12:29

Maybe This topic will give you some insight about the AccesText.

查看更多
登录 后发表回答