我的问题是我的复选框内容不显示下划线或&
符号。我已经读过有关该RecognizeAccessKey
属性的信息,但是我无法使其正常工作。我的列表框如下所示:
<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemsSource="{Binding Channels}">
<ListBox.ItemTemplate>
<DataTemplate>
<ContentPresenter RecognizesAccessKey="False">
<CheckBox Content="{Binding Item}"
IsChecked="{Binding IsChecked}"
Width="149"
MinWidth="149" />
</ContentPresenter>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
谁能告诉我如何解决此问题,以便Checkbox的内容显示下划线和&
符号?
非常感谢你!
您可以使用TextBlock
as CheckBox.Content
,而不是直接绑定它,并绑定它的Text
属性
<CheckBox IsChecked="{Binding IsChecked}" Width="149" MinWidth="149">
<CheckBox.Content>
<TextBlock Text="{Binding Item}"/>
</CheckBox.Content>
</CheckBox>
Run Code Online (Sandbox Code Playgroud)
默认情况下CheckBox
会TextBlock
在AccessText
显示时自动换行Content