Skip to main content

Microsoft Silverlight

Answered Question RC0 - TextAlignment in Style Setter for Button causes System.Windows.Markup.XamlParseException:RSS Feed

(0)

dbaechtel
dbaechtel

Member

Member

59 points

207 Posts

RC0 - TextAlignment in Style Setter for Button causes System.Windows.Markup.XamlParseException:

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
coughlinj

Member

Member

334 points

114 Posts

Answered Question

Re: RC0 - TextAlignment in Style Setter for Button causes System.Windows.Markup.XamlParseException:

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.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities