zoukankan      html  css  js  c++  java
  • 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;
    }




  • 相关阅读:
    Mobile phones(poj1195)
    Matrix(poj2155)
    1080
    1266
    codeforces626D . Jerry's Protest
    字符串格式化
    附加MySQL数据库的方法
    avaScript中变量的声明和赋值
    选择法排序
    JavaScript中变量的类型
  • 原文地址:https://www.cnblogs.com/bkycjj/p/3447407.html
Copyright © 2011-2022 走看看