I'm learning WPF and have been trying to create a toolstrip. Is there a direct equivalent of the WinForms ToolStripButton or is the correct way of use just to add a normal button and format it?
I've found that Microsoft have a page that lists WinForm controls and their WPF equivalents here but that doesn't mention the toolstripbutton.
You can just put buttons inside a ToolBar and it will change the style of the buttons to make them look like a toolbar.
<ToolBar>
<Button>Save</Button>
<Button>Open</Button>
</ToolBar>
Looks like this:
If you want images in the buttons, you have to do the normal thing of modifying the content of the button.
<Button>
<Image Source="..." />
</Button>
Related
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
What's the best way to use glyphs for buttons ?
I have an WPF app which has a lot of buttons and I wonder what's the best way to use them.
I think it's about deploying the app.
Thank's
Example:
<BarButtonItem Name="buttonItem0" Content="Button Item" Glyph="pack://application:,,,/Resources/Images/icon.png" Description="Test button item" Hint="Testing glyph on button" ItemClick="notImplemented" CommandParameter="none" />
<BarButtonItemLink BarItemName="buttonItem0" />
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.
Is there any way to force a radio button or check box to show properly in a toolbar? The circle/check box always disappears once its placed inside a toolbar.
By default, WPF overrides RadioButtons to make them look like toggle buttons. To eliminate this, place a panel inside the ToolBar and then put your RadioButton(s) in there.
<ToolBar>
<StackPanel>
<RadioButton Content="Radio Button" />
</StackPanel>
</ToolBar>
I need a simple HTML renderer ( like HtmlTexBlock ) which also allows to intercept click on custom defined link ( like LinkLabel ) looking like hyperlink. Does anything like that exist as free software ?
I don't know of any but if you only want one link in your html text could you maybe template a button using the htmltextblock as the content and capture the click event and navigate to desired page. I know it will not work if you have multiple links in your html text however it is unclear what your exact requirment is.
eg.
<Button x:Name="btnhtml" Width="63" >
<htmltextblock Text="Hello World"></htmltextblock>
</Button>