Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command Shortcut text string format

Tags:

wpf

I want to set my button tooltip by showing its shortcut key command.

<Button Command="Cut" 
            CommandTarget="{Binding ElementName=textBox}"
            Content="{Binding RelativeSource={RelativeSource Self},Path=Command}"
            ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Command.InputGestures[0]}"/>

But, it shows the result:

enter image description here

It shows "Ctrl+X, Ctrl+X". I just want only a "Ctrl+X". Please help me. I am the beginner.

like image 341
Sokheang Khun Avatar asked Sep 03 '26 12:09

Sokheang Khun


1 Answers

I just found the easy way here.

<Button Command="Cut"
            DockPanel.Dock="Top"
            CommandTarget="{Binding ElementName=textBox}"
            Content="{Binding RelativeSource={RelativeSource Self},Path=Command}"
            ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Command.InputGestures[0].DisplayString}" />
like image 111
Sokheang Khun Avatar answered Sep 05 '26 04:09

Sokheang Khun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!