locked
IsLightDismissEnabled=“True” is not actually dismissing the popup

    Question

  • i have a pop up and i want to close it when i tap anywhere outside the pop up. i searched on the internet and everyone advised me to use the property IsLightDismissEnabled; however, when i use it,  if i touch outside, it will only remove the pop over leaving everything inactive with a grey like screen as if it didnt close the pop up completely. this is my code snippet:

    <Popup x:Name="logincontroler" IsOpen="False" Margin="0,190,896,276" IsLightDismissEnabled="True">
                <StackPanel Height="300" Width="470" x:Name="popup" FlowDirection="RightToLeft">
                    <Grid Width="470" Background="White" >
                        <Grid.RowDefinitions>
                            <RowDefinition Height="70"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <RichEditBox Grid.Row="1" Height="250" TextWrapping="Wrap" FontSize="20" Name="notesPopupTextBox" FlowDirection="LeftToRight"/>
                        <StackPanel Grid.Row="0" Orientation="Horizontal" Background="#FFE3E3E5">
                            <Button Name="CanclePopupButton" Content="Cancel" Width="64" Height="64" Click="CanclePopupButton_Click" />
                            <Button Name="ClearNotePopupButton" Content="Clear" Width="64" Height="64" Click="ClearNotePopupButton_Click" />
                            <Button Name="saveNoteButton" Content="Save" Width="64" Height="64" Click="saveNoteButton_Click" />
    
                            <TextBlock FontWeight="Medium"  FontSize="40" Foreground="#2a2a86" Margin="170 12 0 0">Note</TextBlock>
                        </StackPanel>
                    </Grid>
                </StackPanel>
            </Popup>
    Am I missing anything? thank you in advance

    Wednesday, April 1, 2015 9:23 AM

All replies

  • Hi Pascaleaa,

    I have tested your xaml code in my side, when I touch outside, it will remove the Popup completely. So I can not reproduce your issue in my side. Since you do not post the .cs code in here, I wonder if your .cs code has some influence on that, so could you please try to restart your Visual Studio and create a simple project which just uses the IsLightDismissEnabled=“True” with the Popup control to see if it works? Besides, it will be better if you can post a simple reproduce project in here.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Thursday, April 2, 2015 3:34 AM
    Moderator
  • I tried to set the isOpen to true in the popup like you told me to do and the popup works completely fine; however when i set it to false and add the events it doesn't work properly.

    please find below a snippet of my .cs code:

     private void openNotesPopup()
            {
                scrollViewer1.IsEnabled = false;
                this.Opacity = .4;
                logincontroler.IsOpen = true;
                popup.Width = Window.Current.Bounds.Width;
                notesPopupTextBox.Focus(Windows.UI.Xaml.FocusState.Keyboard);
                Window.Current.Activated += OnWindowActivated;
    
    
            }
            private void OnWindowActivated(object sender, Windows.UI.Core.WindowActivatedEventArgs e)
            {
                if (e.WindowActivationState == Windows.UI.Core.CoreWindowActivationState.Deactivated)
                {
                    this.logincontroler.IsOpen = false;
    
                }     
            }
     
            private void openNotePopUp_Click(object sender, RoutedEventArgs e)
            {
                openNotesPopup();
                   
            }
            private void closeNotesPopup()
            {
    
                logincontroler.IsOpen = false;
                this.Opacity = 1.0;
                scrollViewer1.IsEnabled = true;
            }
           
            private void saveNoteButton_Click(object sender, RoutedEventArgs e)
            {
           
                string tmpNote = "";
               
                notesPopupTextBox.Document.GetText(Windows.UI.Text.TextGetOptions.None, out tmpNote);
                
          
            }
            private void ClearNotePopupButton_Click(object sender, RoutedEventArgs e)
            {
                string tmpNote = "";
                notesPopupTextBox.Document.SetText(TextSetOptions.ApplyRtfDocumentDefaults, tmpNote);
                notesPopupTextBox.Focus(Windows.UI.Xaml.FocusState.Keyboard);
            }
            private void CanclePopupButton_Click(object sender, RoutedEventArgs e)
            {
                closeNotesPopup();
            }
    
    Many thanks

    Thursday, April 2, 2015 6:28 AM
  • Hi Pascaleaa,

    >>however when i set it to false and add the events it doesn't work properly.

    Since I do not have your code about scrollViewer1, so I just delete the code about the scrollViewer1. After that I have done a test in my side but I still can not reproduce your issue. When I tap anywhere outside the popup control, it will remove the popup control, besides I have also tested your events which work fine.
    The following is my result screenshot:

    Please try to rebuild your project or copy your code to a new empty project to see if it works.
    If I have misunderstood you, please feel free to let me know.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Thursday, April 16, 2015 5:47 AM
    Moderator