wpf 点击button,下拉Popup显示按钮或信息

类似于360点击三角按钮,下拉显示更多按钮.这里用到Popup

<Button x:Name="menu"  HorizontalAlignment="Right" Height="24" VerticalAlignment="Top" Width="39.75" Margin="0,1,79.8,0" Click="menu_Click" />
        <Popup x:Name="menuPop1" StaysOpen="False" Margin="0" PlacementTarget="{Binding ElementName=menu}" AllowsTransparency="True">
            <Grid Height="78" Width="100" HorizontalAlignment="Left">
                <Border BorderThickness="0" CornerRadius="3" Background="White" Margin="3">
                    <Border.Effect>
                        <DropShadowEffect ShadowDepth="0" Color="#FFB6B6B6"/>
                    </Border.Effect>
                    <StackPanel Margin="0">
                        <TextBlock Text="hello"></TextBlock>
                        <MenuItem Header="设置" FontSize="12"  Height="23.5" FontFamily="Microsoft YaHei"/>
                        <MenuItem Header="关于" FontSize="12"Height="23.5" FontFamily="Microsoft YaHei"/>
                        <MenuItem Header="退出" FontSize="12" Height="23.5" FontFamily="Microsoft YaHei" Background="#00000000"/>
                    </StackPanel>
                </Border>
            </Grid>
       </Popup>

上面popup中的  PlacementTarget="{Binding ElementName=menu}"

是关联控件的意思

再加入后台代码:
private void menu_Click(object sender, RoutedEventArgs e)
{
      menuPop1.IsOpen = true;
}

 





posted @ 2013-11-28 12:01  Jimmy_5  阅读(4246)  评论(1编辑  收藏  举报