POPUP DOES NOT CLOSED EVENT STAYOPEN SET AS FALSE

Chintoo Semi

Total Post:135

Points:947
Posted by  Chintoo Semi
C# 
C#
 934  View(s)
Ratings:
Rate this:

I have use the following code snippet to define the Popup.

XAML:

  <Grid Margin="0,0,0,0"  Height="40">      
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="Auto" />
      <ColumnDefinition Width="19" />
      <ColumnDefinition Width="19" />
    </Grid.ColumnDefinitions>
    <TextBlock HorizontalAlignment="Stretch"
               Text="HeaderText"                        
               FontWeight="Bold"
               TextTrimming="CharacterEllipsis"
               VerticalAlignment="Center"/>
       <Grid Grid.Column="1">
         <Button Width="19" x:Name="FilterButton" Click="FilterButton_OnClick" Content="^"/>
         <Popup x:Name="FilterPanel" StaysOpen="False"   >
           <Border >
             <Grid>
               <TextBlock x:Name="tblTitle" Text="PopUp Header" Background="Red" Grid.Column="0" Grid.Row="0"/>
             </Grid>
           </Border>
         </Popup>
       </Grid>
    <TextBox Text="Test" Grid.Column="2"/>
  </Grid>

I have use the following code snippet to open the popup

C#:

private void FilterButton_OnClick(object sender, RoutedEventArgs e)
{
     this.FilterPanel.IsOpen = true;
}

Scenorio:

Open the popup using button click.

Actual Behavior:

Popup does not close.

Expected Behavior:

Popup should be closed.

Thanks in advance.

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: Popup does not closed event Stayopen set as False

    Hi Chintoo,


    Try this:
    FilterPanel.IsMouseCaptureWithinChanged
    +=FilterPanel_IsMouseCaptureWithinChanged;
    void FilterPanel_IsMouseCaptureWithinChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (!(bool)e.NewValue)
            { FilterPanel.IsOpen = false; }
        }

      Modified On Apr-04-2018 02:19:23 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!