4

I have a WPF application in which I try to rename a button like that << Précédent

<Button Content="Suivant >>" Background="#FFF9F7F7" Margin="0,0,100,8"
        HorizontalAlignment="Right" Width="75" Height="22" VerticalAlignment="Bottom"
        RenderTransformOrigin="0.5,0" BorderBrush="CadetBlue"  BorderThickness="2" />
<Button Content="<< Précédent" Background="White" Margin="0,0,180,8"
        HorizontalAlignment="Right" Width="75" Height="22" VerticalAlignment="Bottom"
        BorderBrush="CadetBlue"  BorderThickness="2" />

But an error appears in the second button name

  1. Why doesn't this work?
  2. How can i fix it?
Abbas
  • 14,186
  • 6
  • 41
  • 72
Lamloumi Afif
  • 8,941
  • 26
  • 98
  • 191
  • 1
    "an error occurs" gives us very little information... – Jon Skeet Jan 20 '14 at 14:49
  • You should note that `>>` and `»` and `<<` and `«` are different characters - especially since `>>` and `<<` are really two characters, while the others are a single character. If you want to use `>>`, go with Jon Skeet's answer. – Thorsten Dittmar Jan 20 '14 at 14:53
  • This looks like french to me (right?). IMO, with all UI elements in production code, you should globalise (prepare for translation) all strings using a `resx` file and the `{x:Static}` mark up extension. As a bonus, you no longer have to use the escape sequences. http://stackoverflow.com/a/2170357/286976 – Gusdor Jan 20 '14 at 14:59

1 Answers1

10

I suspect this is just a matter of XML escaping for <, as you can't use < directly within an attribute value. Try:

<Button Content="&lt;&lt; Précédent" ...>

... and please provide more details in your next question.

(You'd need the same escaping for XML content too, as otherwise it will be treated as the start of a new element.)

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194