Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Popup in WPF

0.00/5 (No votes)
30 Jan 2014 1  
Use of popup of WPF to use as a selection menu

Introduction

This tip is about the use of popup of WPF to use as a selection menu. Here is the code snippet to have a look at.

Using the Code

The code should be set as style "Formatted" like this:

<Button x:Name="generatebtn" Content="Generate" 
Height="25" Margin="10" Width="60" Click="generatebtn_Click" />

            <Popup x:Name="popup" IsOpen="False" 
            PlacementTarget="{Binding ElementName=selFilesbtn}" 
            Placement="Top" Width="146">
                <Border BorderBrush="Black" BorderThickness="1" 
                Background="AliceBlue">
                    <StackPanel Orientation="Horizontal">
                        <Grid Width="142">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto" />

                            </Grid.RowDefinitions>
                            <GroupBox Header="Review As" 
                            HorizontalAlignment="Left" VerticalAlignment="Top" 
                            Grid.Row="0">
                                <StackPanel>
                                    <RadioButton x:Name="currentSelectionBtn" 
                                    Content="CurrentSelection"/>
                                    <RadioButton x:Name="singleFileBtn" 
                                    Content="As Single File"/>
                                </StackPanel>
                            </GroupBox>
                            <Button x:Name="generateAsBtn" Content="Generate" 
                            Grid.Row="1" Click="generateAsBtn_Click" />
                        </Grid>
                    </StackPanel>
                </Border>
            </Popup>  

Here is the image of how the popup will appear.

Now after using this code snippet, the output will look like the image shown. In this code snippet, the image is aligned to the button on which the popup menu is made visible.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here