Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit RC0 - TextAlignment in Style Setter for Button causes System.Windows.Markup.XamlParseException:
1 replies. Latest Post by coughlinj on September 26, 2008.
(0)
dbaechtel
Member
59 points
207 Posts
09-26-2008 3:54 PM |
I have a recent MSDN magazine sample code for Silverlight 2.0 and I am trying to run it with Silverlight RC0. When I run the code it gets a System.Windows.Markup.XamlParseException on the LoadComponent(App.xaml) on the following line in a Style Setter for TargetType="Button" : vsm:Setter Property="TextAlignment" Value="Center" This is apparently another recent breaking change. How do I set the TextAlignment in a Button Style in SL RC0? The same seems to be true for TextWrapping in Style for Button. How do I set the TextWrapping property?
coughlinj
334 points
114 Posts
09-26-2008 4:22 PM |
Yes TextAlignment and TextWrapping have been removed as per the breaking change doc.
One way of getting around the alignment is just to use HorizontalContentAlignment. It of course will affect all content of the button.
The text wrapping (and for that matter the TextAlignment) can be specified on a TextBlock that is used as the content of the button. For example...
<Button VerticalContentAlignment="Bottom" HorizontalContentAlignment="Left"> <TextBlock Text="Hello world" TextWrapping="Wrap" /> </Button>
This would be the equivalent of Beta 2's
<Button Content="Hello world" TextAlignment="Left" TextWrapping="Wrap" />
Hope that helps I realize your situation maybe more complicated.