locked
Pop Up

    Question

  • I am using pop ups in my app , How could i allow to show a single pop up when i click a button , and when i click a different button close the opened pop up screen and then open the new one ????? I need an example 

    I am working through Visual Studio Express 2012

    Tuesday, November 11, 2014 8:33 PM

Answers

  • What kind of pop ups? If you mean a Popup element, you could simply set its IsOpen property to true/false to open/close it:

    <Popup x:Name="popup1" IsOpen="True">
                <Grid Background="Yellow" Width="100" Height="100">
                    <TextBlock FontSize="20" Foreground="Black">1</TextBlock>
                </Grid>
            </Popup>
            
            <Popup x:Name="popup2" IsOpen="False">
                <Grid Background="Yellow" Width="100" Height="100">
                    <TextBlock FontSize="20" Foreground="Black">2</TextBlock>
                </Grid>
            </Popup>
    
            <Button Margin="100" Content="Open" Click="Button_Click"/>
    

    private void Button_Click(object sender, RoutedEventArgs e)
            {
                popup1.IsOpen = false;
                popup2.IsOpen = true;
            }
    

    Tuesday, November 11, 2014 9:40 PM