La semana pasada me vi en la necesidad de crear un popup que ocupara la pantalla completa del dispositivo pensé que sería algo difícil implementarlo pero en realidad es muy fácil ya que contamos con las propiedades Application.Current.Host.Content.ActualHeight y Application.Current.Host.Content.ActualWidth que son aquellas que nos retornan el ancho y alto de la pantalla del dispositivo.
Aqui dejo un code snippet para que vean como se puede implementar.
public void showPopUp()
{
//obtenemos el ancho y el alto
double height=Application.Current.Host.Content.ActualHeight;
double width = Application.Current.Host.Content.ActualWidth;
//stackpanel
StackPanel stk = new StackPanel();
//establecemos el tamaño del height al stackpanel
stk.Height = height;
//establecemos el tamaño del witdh al stackpanel
stk.Width = width;
//color de fondo
stk.Background = new SolidColorBrush(Colors.Red);
//textblock
TextBlock txtblock = new TextBlock() { FontSize=40, Text="HELLO WORLD", TextWrapping=TextWrapping.Wrap};
//agregamos el textblock al stackpanel
stk.Children.Add(txtblock);
Popup _popup = new Popup();
//child content el stackpanel
_popup.Child = stk;
this.LayoutRoot.Children.Add(_popup);
//mostramos el popup
_popup.IsOpen = true;
}
Este es el resultado que se obtiene :D.

No hay comentarios:
Publicar un comentario