Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Look I don't really understand what is your problem. Anyway, I created a simple wpf application and put a button on a grid.</p> <pre><code> &lt;Grid&gt; &lt;Button Name="btnButton1" Width="150" Height="70" Click="btnButton1_Click" /&gt; &lt;/Grid&gt; </code></pre> <p>After in code</p> <pre><code> private void Window_Loaded(object sender, RoutedEventArgs e) { btnButton1.Content = "E_xit"; } </code></pre> <p>So now when I keep Alt pressed the letter x is underscored. If when Alt is pressed I press x then the <code>btnButton1_Click</code> event is fired and I see a message box.</p> <pre><code>private void btnButton1_Click(object sender, RoutedEventArgs e) { MessageBox.Show("1111"); } </code></pre> <p>As you see I have created the content in code.</p> <p>P.S. If you are using a custom content template then read this <a href="https://stackoverflow.com/questions/7416303/how-to-use-an-accesskey-on-a-wpf-button-with-a-custom-contenttemplate">custom content template</a></p> <p>If you just need to make one letter underlined then</p> <pre><code> StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Horizontal; stackPanel.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; TextBlock textBlock = new TextBlock(); textBlock.Text = "E"; stackPanel.Children.Add(textBlock); textBlock = new TextBlock(); textBlock.TextDecorations = System.Windows.TextDecorations.Underline; textBlock.Text = "x"; stackPanel.Children.Add(textBlock); textBlock = new TextBlock(); textBlock.Text = "it"; stackPanel.Children.Add(textBlock); btnButton1.Content = stackPanel; </code></pre> <p>Just use it in any event handler!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload