Popup 控件

Popup:在一个单独的窗口中显示内容,该窗口浮动在当前应用程序窗口之上。

<Window x:Class="MaterialStorage.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="20"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="20"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" ></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <DockPanel Grid.Row="0" Grid.Column="1" Height="20" HorizontalAlignment="Stretch" Name="dockPanel1" Margin="0" VerticalAlignment="Top">
            <Menu Name="menu1" Width="Auto" DockPanel.Dock="Top"
VerticalAlignment="Center"  >
                <MenuItem Header="文件">
                    <MenuItem Header="报表导出" Name="newMember" />
                    <MenuItem Header="数据备份" Name="saveMember" />
                    <Separator/>
                    <MenuItem Header="关闭" Name="exit" />
                </MenuItem>
                <MenuItem Header="关于"  />
            </Menu>
        </DockPanel>
        <Grid Grid.Row="1" Grid.Column="1" Background="Beige">
            <Image Name="image1" Source="http://i.ssimg.cn/ssupload/2013/02/28/c92380f19fbb4127861c8ec3c836eb48.jpg" Height="200" Width="200"/>
            <Popup IsOpen="False" PlacementTarget="{Binding ElementName=image1}" Placement="Bottom">
                <TextBlock FontSize="14" Background="LightGreen">Placement=Bottom</TextBlock>
            </Popup>
            <Popup IsOpen="True" PlacementTarget="{Binding ElementName=image1}" Placement="Top">
                <TextBlock FontSize="14" Background="LightGreen">Placement=Top</TextBlock>
            </Popup>
            <Popup IsOpen="True" PlacementTarget="{Binding ElementName=image1}" Placement="Left">
                <TextBlock FontSize="14" Background="LightGreen">Placement=Left</TextBlock>
            </Popup>
            <Popup IsOpen="True" PlacementTarget="{Binding ElementName=image1}" Placement="Right">
                <TextBlock FontSize="14" Background="LightGreen">Placement=Right</TextBlock>
            </Popup>
        </Grid>
        <DockPanel Grid.Row="2" Grid.Column="1"  Height="20" HorizontalAlignment="Stretch" Name="dockPanel2" Margin="0" VerticalAlignment="Bottom">
            <StatusBar Height="20" Name="statusBar1" Width="Auto" DockPanel.Dock="Top" VerticalAlignment="Center"   >
                <TextBlock Name="statusValue">fff</TextBlock>
            </StatusBar>
        </DockPanel>
    </Grid>
</Window>

原文地址:https://www.cnblogs.com/zhuzhenyu/p/2937313.html