WrapPanel does not contain its children

I am trying to make this grid layout for a list of patients having the FirstName And LastName centered regardless the viewport width (for instance on an Iphone 6 view FirstName and LastName should be inline but on an Iphone5 view the Firstname should be placed on one line and LastName on the line below, both names centered of course). I am using to Text elements since the Values are bound from the JS. I posted the code for just one item in the grid since they all come from an Each iterator.


<StackPanel Margin="0,0,0,10" Padding="10" ux:Class="PatientListItem">
    <Viewbox StretchDirection="DownOnly" Margin="0,0,0,10">
        <Circle Width="250" Height="250" ClipToBounds="true">
            <Stroke Width="1" Brush="#aaa"/>
            <ImageFill StretchMode="UniformToFill">
                <HttpImageSource Url="{image}"/>
    <StackPanel Background="#f90" >
        <WrapPanel Alignment="HorizontalCenter" Background="#f00" >
            <Rectangle  Fill="#0f0"> <Stroke Width="2" Brush="#f00"/>
                <Text Value="{givenName}" TextAlignment="Center" TextColor="{textColor}" FontSize="13"></Text>
            <Text Value=" "/>
            <Rectangle  Fill="#0f0"> <Stroke Width="2" Brush="#f00"/><Text Value="{familyName}" TextAlignment="Center" TextColor="{textColor}" FontSize="13"/></Rectangle>
        <Panel Alignment="HorizontalCenter">
            <Text Value="{@type}" TextColor="{memoriaColor}" Alignment="Center" FontSize="12"/>



So far, so good, but when the viewport is smaller the preview looks like this: (The WrapPanel contents overflow.)


Ok. Then I remove the HorizontalCenter Alignment from the WrapPanel and the contents (Firstname and LastName) are normally contained in the WrapPanel.


The overflow happens with Center Alignment, too. So how am I supposed to center the WrapPanel inside its parent StackPanel? Is this a bug? Waiting for workarounds, Thanks.

I think this is basically the same question as https://www.fusetools.com/community/forums/bug_reports/text_wrap_problem_using_wrappanel_with_center_alig

Without doing the string concatenation in JS now there is no real way to achieve what you want. WrapPanel doesn’t support ContentAlignment yet.