<p>I am setting the <code>.Content</code> value of a Label to a string that contains underscores; the first underscore is being interpreted as an accelerator key.</p>

<p>Without changing the underlying string (by replacing all <code>_</code> with <code>__</code>), is there a way to disable the accelerator for Labels?</p>

[{'answer_id': 40784, 'author': 'denis phillips', 'author_id': 748, 'author_profile': 'https://Stackoverflow.com/users/748', 'pm_score': 5, 'selected': False, 'text': '<p>You could override the RecognizesAccessKey property of the ContentPresenter that is in the default template for the label. For example:</p>\n\n<pre><code>&lt;Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;\n  &lt;Grid&gt;\n    &lt;Grid.Resources&gt;\n      &lt;Style x:Key="{x:Type Label}" BasedOn="{StaticResource {x:Type Label}}" TargetType="Label"&gt;\n        &lt;Setter Property="Template"&gt;\n          &lt;Setter.Value&gt;\n            &lt;ControlTemplate TargetType="Label"&gt;\n              &lt;Border&gt;\n                &lt;ContentPresenter\n                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"\n                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"\n                  RecognizesAccessKey="False" /&gt;\n              &lt;/Border&gt;\n            &lt;/ControlTemplate&gt;\n          &lt;/Setter.Value&gt;\n        &lt;/Setter&gt;\n      &lt;/Style&gt;\n    &lt;/Grid.Resources&gt;\n    &lt;Label&gt;_This is a test&lt;/Label&gt;\n  &lt;/Grid&gt;\n&lt;/Page&gt;\n</code></pre>\n'}, {'answer_id': 3211015, 'author': 'yota', 'author_id': 387522, 'author_profile': 'https://Stackoverflow.com/users/387522', 'pm_score': 8, 'selected': True, 'text': '<p>If you use a TextBlock as the Content of the Label, its Text will not absorb underscores.</p>\n'}, {'answer_id': 43497326, 'author': 'satheesh reddy', 'author_id': 4929487, 'author_profile': 'https://Stackoverflow.com/users/4929487', 'pm_score': 1, 'selected': False, 'text': '<p>Use a <code>&lt;TextBlock&gt; ... &lt;/TextBlock&gt;</code>\ninstead of <code>&lt;Label&gt; ... &lt;/Label&gt;</code> to print the exact text, which is having underscores.</p>\n'}, {'answer_id': 44116685, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>Why not like this?</p>\n\n<pre><code>public partial class LabelEx : Label\n    {\n        public bool PreventAccessKey { get; set; } = true;\n\n        public LabelEx()\n        {\n            InitializeComponent();\n        }\n\n        public new object Content\n        {\n            get\n            {\n                var content = base.Content;\n                if (content == null || !(content is string))\n                    return content;\n\n                return PreventAccessKey ?\n                    (content as string).Replace("__", "_") : content;\n            }\n            set\n            {\n                if (value == null || !(value is string))\n                {\n                    base.Content = value;\n                    return;\n                }\n\n                base.Content = PreventAccessKey ?\n                    (value as string).Replace("_", "__") : value;\n            }\n        }\n    }\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/40733', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2258/']