Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Button content with '&' not accepting

Tags:

button

wpf

xaml

I am creating and with content 'Save & Add'. I write it in XAML, but the symbol '&' is not accepting. What is the reason for that. How can I do that?

like image 419
Sauron Avatar asked Aug 03 '09 05:08

Sauron


People also ask

How do I style a button in WPF?

Create a Basic Button in WPFClick the file menu and select New then click on the project. Find the Windows Desktop WPF Application template. Step 3: Change the default Grid element into StackPanel and use the default buttons inside the StackPanel, as in the following code: <Window x:Class="WpfApplication1.

Which property of the button tool is used to set whether the button will respond to an event or not?

Its content property is Content. Handle the ButtonBase. Click event to respond when the user clicks a Button. The OnMouseLeftButtonDown method marks the MouseLeftButtonDown event as handled.

What is TextBlock WPF?

The TextBlock control provides flexible text support for UI scenarios that do not require more than one paragraph of text. It supports a number of properties that enable precise control of presentation, such as FontFamily, FontSize, FontWeight, TextEffects, and TextWrapping.


2 Answers

Use &amp; instead of &.

You might find this article of some use - How to: Use Special Characters in XAML

like image 145
Ben Griswold Avatar answered Nov 13 '22 02:11

Ben Griswold


From Wikipedia:

Unlike traditional HTML with its large range of character entity references, in XML there are only five predefined character entity references. These are used to escape characters that are markup sensitive in certain contexts:

  • &amp; → & (ampersand, U+0026)
  • &lt; → < (less-than sign, U+003C)
  • &gt; → > (greater-than sign, U+003E)
  • &quot; → " (quotation mark, U+0022)
  • &apos; → ' (apostrophe, U+0027)
like image 27
Cameron MacFarland Avatar answered Nov 13 '22 02:11

Cameron MacFarland