WPF列表框。跳过字符串下划线符号 [英] WPF listbox. Skip underscore symbols in strings

查看:218
本文介绍了WPF列表框。跳过字符串下划线符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些WPF列表框是动态的项目填充。事情是这样的:

I have some WPF ListBox which is dynamically populating with items. Something like this :

ListBox.Items.Add
(new ListBoxItem { Content = new CheckBox { IsChecked = true, Content = "string_string"} );



问题是与复选框的内容。它显示像stringstring......
GUI如何逃离_符号? (我得到的字符串动态)

The problem is with checkbox content. It's showing on GUI like "stringstring"... How to escape the "_" symbols ? (I get strings dynamically)

推荐答案

您可以添加一个TextBlock文本,并将该TextBlock的您Chekbox里面,TextBlock的不支持_助记字符。这就是我的意思是,在XAML,但你可以很容易地转换为代码:

You can add the text in a TextBlock and put that TextBlock inside your Chekbox, TextBlock does not support _ mnemonic characters. Here's what I mean, in xaml, but you can easily convert this to code:

<CheckBox IsChecked="True">
    <TextBlock>string_string</TextBlock>
</CheckBox>

这篇关于WPF列表框。跳过字符串下划线符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆