locked
How do I center and stretch(horizontally) a Popup within a page like how dialogs have by default

    Question

  • A dialog appears in the horizontal center stretched with the following code.

    var dialog = new CoreWindowDialog("This appears in perfect center horizontally stretched");
    dialog.ShowAsync();

    However the following popup code appears below the horizontal center and right of vertical center without being stretched.

    XAML

    <Popup x:Name="myPopup" 
                   HorizontalAlignment="Center" 
                   VerticalAlignment="Center">
                <Border BorderBrush="{StaticResource ApplicationForegroundThemeBrush}" 
                    Background="{StaticResource ApplicationPageBackgroundThemeBrush}"
                    BorderThickness="2" Width="Auto" Height="Auto">
                    <TextBlock Text="This doesn't appear in the center and doesn't stretch horizontally" FontSize="30" MinHeight="100" MinWidth="300" />
                </Border>
            </Popup>

    c#

    myPopup.IsOpen = true;

    I need a popup because I want to add custom images instead of plain text/ui commands.

    The question is how do I set the parameters of the Popup so that it appears the way a dialog does (Center and stretched)

    Thanks in Advance.

    Thursday, February 13, 2014 4:00 PM

Answers

  • Create your popup full screen and embed a Grid with three rows. Put the controls centered in the middle row. If you search you should find several example controls which implement this dialog erect for you.
    Thursday, February 13, 2014 4:05 PM
    Owner