Align Popup to Center

Asked

Viewed 107 times

3

Why can’t I line up at the center, that my popup?

Popup

Look how he looks in XAML Design

inserir a descrição da imagem aqui

Follows my XAML:

<Popup x:Name="popup" HorizontalAlignment="Center" VerticalAlignment="Center">
    <StackPanel Background="Black" Width="456">
        <TextBlock Text="Selecione uma ação:" Name="lblInformaPopup" Margin="10,0" VerticalAlignment="Center" Style="{StaticResource PhoneTextTitle2Style}" />
        <StackPanel HorizontalAlignment="Center" Orientation="Horizontal" VerticalAlignment="Top">
            <Image Name="imgPhone" Source="Assets/Images/telefone.png" Width="70" Height="70" Tap="imgPhone_Tap" />
            <Image Name="imgGps" Source="Assets/Images/gps.png" Width="70" Height="70" Tap="imgGps_Tap" Margin="15,0,0,0"  />
            <Image Name="imgEmail" Source="Assets/Images/email.png" Width="70" Height="70" Margin="15,0,0,0"  />
        </StackPanel>
    </StackPanel>
</Popup>

Suggestions?

  • Good afternoon, see if this example helps you: var p = new Popup();&#xA;var content = new TextBox { Text = "hello world!" };&#xA;p.Child = content;&#xA;p.VerticalOffset = (this.ActualHeight - content.ActualHeight) / 2;&#xA;p.HorizontalOffset = (this.ActualWidth - content.ActualWidth) / 2;&#xA;p.IsOpen = true;

  • what is that content ? @cavalsilva. Why do you think he doesn’t exist: The name 'content' does not exist in the Current context

1 answer

1


You must define the dimensions of the tag Popup in order to centralize it.

For example:

<Popup x:Name="popup" HorizontalAlignment="Center" VerticalAlignment="Bottom" Width="456" Height="70">
    <StackPanel Background="Black" Width="Auto" HorizontalAlignment="Center">
        <TextBlock Text="Selecione uma ação:" Name="lblInformaPopup" Margin="10,0" VerticalAlignment="Center" Style="{StaticResource PhoneTextTitle2Style}" />
        <StackPanel HorizontalAlignment="Center" Orientation="Horizontal" VerticalAlignment="Top">
            <Image Name="imgPhone" Source="Assets/Images/telefone.png" Width="70" Height="70" Tap="imgPhone_Tap" />
            <Image Name="imgGps" Source="Assets/Images/gps.png" Width="70" Height="70" Tap="imgGps_Tap" Margin="15,0,0,0"  />
            <Image Name="imgEmail" Source="Assets/Images/email.png" Width="70" Height="70" Margin="15,0,0,0"  />
        </StackPanel>
    </StackPanel>
</Popup>

In this case, I defined the dimensions for the <Popup> and the <StackPanel> inherits the dimensions of <Popup> using Auto.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.