Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename a button with < character in wpf

Tags:

c#

.net

wpf

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?
like image 973
Lamloumi Afif Avatar asked Dec 26 '22 14:12

Lamloumi Afif


1 Answers

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.)

like image 114
Jon Skeet Avatar answered Jan 03 '23 12:01

Jon Skeet