Create PopUp Window in C# WPF


To create PopUp window WPF provide a popup tag.when i click a button then the pop-up window is open.This pop-up window contain a listview.The pop-up window is closed when leaving the mouse from other place.
Here is the code for creation pop-up window

<Popup Name="PopupEsales" Placement="Right" IsEnabled="True" IsOpen="False" Grid.RowSpan="2">
    <ListView Height="145" HorizontalAlignment="Stretch" Margin="0,0,0,0" Name="lvSalesPersonIdSearch" VerticalAlignment="Top" Width="257" SelectionChanged="lvSalesPersonIdSearch_SelectionChanged">
        <ListView.View>
            <GridView>
                <GridViewColumn Header="Sales Persons Id" Width="100" DisplayMemberBinding="{Binding Path=SPID}" />
                <GridViewColumn Header="Name" Width="100" DisplayMemberBinding="{Binding Path=Name}" />
            </GridView>
        </ListView.View>
    </ListView>
</Popup>

This following code under the button to open the pop-up window

private void btnSearchInfo_Click(object sender, RoutedEventArgs e)
    {
        PopupEsales.IsOpen = true;
        lvSalesPersonIdSearch.Items.Add(aESales);
    }

Pop-Up Close

        private void LayoutRoot_MouseLeave(object sender,MouseEventArgs e)
        {
            PopupEsales.StaysOpen = false;
        }

If you have any query about this topic please leave a comment.

2 Responses to “Create PopUp Window in C# WPF”

  1. ayanahmed Says:

    thanks Mr. Refat38 it’s a too much helpful blog for me.

  2. Towhid Says:

    Thanks for sharing.


Leave a comment