WPF: Hotkey on Button does not appear underlined when pressing ALT-Key - wpf

I have a WPF application where a button is defined through
<Button Command="{Binding ShowSomeDialog}">
<AccessText>_Push me</AccessText>
</Button>
The button does not show the "P" underlined when pressing the ALT-Key, but pressing ALT-P does invoke the command.
In the same application in another window the exact same tag behaves as expected, meaning: it underlines the P when ALT-Key is pressed.
In the context where the HotKey is not underlined, the button is nested deeply. Simplified the hierarchy may be sketched as
Window
syncfusion:TabControlExt
syncfusion:TabItemExt
UserControl
syncfusion:TabControlExt
syncfusion:TabItemExt
UserControl
Button
The HotKey will be underlined if a button is added to the '4. UserControl' and will not be underlined when added to '7. UserControl' or deeper.
I can't find any custom styles for the elements inbetween, especially none in which the RecognizesAccessKey is set to False.
Does anyone have an idea what or where to check?

Check if you have Button restyled somewhere - access key behavior can be easily broken with incorrect style.
And btw, you did try setting Content attribute to "_Push me" directly, without using AccessText, didn't you?
P.S. MSDN may be of help here.

Play with <AccessText ... Margin="0,0,0,X"/> where X is a double value and look if the underscore appears.

Related

Is there a way to access the link inside react-tooltip on hover?

Im using react-simple-maps with react-tooltip
Looks like the hover works fine, but I try to click on a link I've added on the tooltip but before I can get to the tooltip, it disappears and I can't access the content with my mouse.
is this possible?
Depending on what your implementation specifically looks like, I think the delayHide property is what you're looking for. It defines the delay after the hover event ends until the tooltip disappears, in milliseconds.
<ReactTooltip delayHide={1000} />

Create a button with a down arrow icon

I want to create a button with a down arrow icon that displays a menu when clicked. I have found the following button type:
But this button can be pressed in two places (on the left of the vertical line and on the right of the vertical line), also I don't want the button to have a vertical line, I want it to be something like this:
Can this be done in Windows API?
What you are looking for can be done using either:
a standard COMBOBOX control with the CBS_DROPDOWNLIST window style:
(source: s-msft.com)
A Menu button:
(source: s-msft.com)
However, this is not a standard Win32 control. MFC has a CMFCMenuButton class for it, but in Win32 you have to owner-draw a standard BUTTON control to achieve the same effect:
Menu button arrow with raw Win32
When the button is pushed, you can display your pop-up menu as needed, using TrackPopupMenu() or equivalent.

How to use an image as a button in GTK?

How to use an image as a button in GTK in c language in code blocks? I have tried making the button of same color as that of the background and then adding image on it. But there is a outline or shadow still there. So, how can i remove those shadows or is there a way to directly use an image as a button?
One way is outlined by #Shabhaz, by putting the image in an EventBox, and handling the button-press event.
The other way is by placing the image in the button and customizing the style of the button to remove the outline and the shadow. You would call gtk_rc_parse_string() to define an outline-less button class, and gtk_widget_set_name() on your button to apply the style.

MouseDown doesnt work in Grid (only on buttons which in grids)

I have problem with MouseDown event. My app looks like that, I have grid in which im adding buttons in code behind
<Grid Grid.Column="1" Name="gridWithButtons" MouseDown="normalModeButtonsWP_MouseDown" >
<WrapPanel Name="normalModeButtonsWP" MouseDown="normalModeButtonsWP_MouseDown" ></WrapPanel>
</Grid>
But when im pressing mouse button in grid/wrappanel ( i mean in empty space between buttons for example) it doesnt work. Works only when im pressing button which is in wrap/grid. Anyone know how to handle it?
Setting IsHitTestVisible alone will not make it work.
Elements are not clickable if Background is set to None. To make it clickable (applies to grid, stackpanel, etc) set the Background to #00000000. This is a feature by design to prevent users clicking on ghost buttons. However, assigning it a color will make it clickable.
Try setting IsHitTestVisible = true on your grid

How can I underline a single character in the Content of a Button in WPF?

I have a number of buttons in my WPF window and I would like to have certain characters in the button contents underlined.
I have tried using the "_" like "My_Content" to underline the C, however this does not appear until the user hits the Alt key, or has their local settings changed. Using < Underline > within the Content property causes an error when I attempt to underline only part of the content like:
Content="My< Underline >C< /Underline >ontent".
I would prefer to set this in the XAML if possible. Any help would be appreciated.
Thank You!
You would have to do this explicitly like so:
<Button>
<Button.Content>
<TextBlock>
My <Underline>C</Underline>ontent
</TextBlock>
</Button.Content>
</Button>
This would remove the ability to click the button using Alt+Char though. For that an AccessText element is used. But that doesn't support the markup syntax of TextBlock.

Resources