我有动态字符串显示为MenuItem的标题,有时包含'_'.WPF将下划线视为助记符的标志,但我不希望如此.我如何禁用它?
在线程WPF列表框中尝试所有解决方案之后.在字符串中跳过下划线符号,这似乎不适用于MenuItems,我这样做:
public class EscapeMnemonicsStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
string str = value as string;
return str != null ? str.Replace("_", "__") : value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Run Code Online (Sandbox Code Playgroud)