New to Telerik UI for WPFStart a free 30-day trial

Displaying Underscores in Named Ranges in WPF Spreadsheet

Updated on Apr 27, 2026

Environment

ProductSpreadsheet for UI for WPF
Version2026.1.415

Description

When using named ranges containing underscores _ in the Spreadsheet control in UI for WPF, the underscores are removed.

This happens because the RadMenuItem element displaying the named ranges automatically enables the WPF access text feature, which interprets underscores as access keys.

Solution

To display the underscores properly, override the Header property of the RadMenuItem elements using a global Loaded event handler. This disables the access text feature by replacing the text content with a TextBlock element.

csharp
static MainWindow()
{
    EventManager.RegisterClassHandler(typeof(RadMenuItem), RadMenuItem.LoadedEvent, new RoutedEventHandler(OnMenuItemLoaded));
}

private static void OnMenuItemLoaded(object sender, RoutedEventArgs e)
{
    var menuItem = (RadMenuItem)sender;
    if (menuItem.DataContext is DefinedName context)
    {
        // Use TextBlock to properly display underscores
        menuItem.Header = new TextBlock() { Text = context.Name };
    }
}

See Also