locked
overlay screen RRS feed

  • Question

  • I am making a game and need an instructions screen over the playing main screen. Now do i use a image that pops up or a new screen with alpha parts to show through main screen?

     

    what can i do with SL?

    Friday, June 12, 2009 8:48 PM

Answers

  •  Hi use the following trick.

    Create a Control with the following XAML

    <UserControl x:Class="SilverlightDialogBoxExample.BaseContainer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
    <Canvas x:Name="dialogContainer" Width="Auto" Opacity=".9" Height="Auto" HorizontalAlignment="Center"
     VerticalAlignment="Center" Visibility="Collapsed"/>
    <Grid x:Name="detailsContainer" Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center"/>

    </Grid>
    </UserControl>
     
    In App.xaml.cs instead of assigning the UserControl you want to display to the RootVisual add it to the BaseContainer control as follows
    BaseContainer baseContainer;
            private void Application_Startup(object sender, StartupEventArgs e)
    {
    baseContainer = new BaseContainer();
    baseContainer.detailsContainer.Children.Add(new MainPage());
    this.RootVisual = baseContainer;
    }
    Create another method ShowDialog in App.xaml.cs
     
            public void ShowDialog(UserControl dialog)
    {
    this.baseContainer.dialogContainer.Children.Clear();
    this.baseContainer.dialogContainer.Visibility = Visibility.Visible;
    this.baseContainer.dialogContainer.Children.Add(dialog);
    }

     

    Now you can popupa dialogbox from your main control using this code

     

    ExampleDialog dlg = new ExampleDialog();
                (App.Current as SilverlightDialogBoxExample.App).ShowDialog(dlg);

     

    Alpha can be set by changing to opacity of the dialogbox.

    Saturday, June 13, 2009 2:12 AM

All replies

  •  Hi use the following trick.

    Create a Control with the following XAML

    <UserControl x:Class="SilverlightDialogBoxExample.BaseContainer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
    <Canvas x:Name="dialogContainer" Width="Auto" Opacity=".9" Height="Auto" HorizontalAlignment="Center"
     VerticalAlignment="Center" Visibility="Collapsed"/>
    <Grid x:Name="detailsContainer" Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center"/>

    </Grid>
    </UserControl>
     
    In App.xaml.cs instead of assigning the UserControl you want to display to the RootVisual add it to the BaseContainer control as follows
    BaseContainer baseContainer;
            private void Application_Startup(object sender, StartupEventArgs e)
    {
    baseContainer = new BaseContainer();
    baseContainer.detailsContainer.Children.Add(new MainPage());
    this.RootVisual = baseContainer;
    }
    Create another method ShowDialog in App.xaml.cs
     
            public void ShowDialog(UserControl dialog)
    {
    this.baseContainer.dialogContainer.Children.Clear();
    this.baseContainer.dialogContainer.Visibility = Visibility.Visible;
    this.baseContainer.dialogContainer.Children.Add(dialog);
    }

     

    Now you can popupa dialogbox from your main control using this code

     

    ExampleDialog dlg = new ExampleDialog();
                (App.Current as SilverlightDialogBoxExample.App).ShowDialog(dlg);

     

    Alpha can be set by changing to opacity of the dialogbox.

    Saturday, June 13, 2009 2:12 AM
  •  is this a known method to display a popup screen?

    Saturday, June 13, 2009 6:35 AM
  • Yes

    Saturday, June 13, 2009 7:44 AM