Popup:

  1. <StackPanel Grid.Column="0" Grid.Row="6" Orientation="Horizontal">
  2. <local:ImageButton x:Name="btn_back2" Margin="10,0,5,0" ImgPath="/Images/返回2.png" Width="112" Height="43" Template="{StaticResource ImageButtonTemplate}" Click="btn_back2_Click" />
  3. <local:ImageButton x:Name="btn_bg" Margin="5,0" ImgPath="/Images/背景.png"  Width="82" Height="43" Template="{StaticResource ImageButtonTemplate}" Click="btn_bg_Click" />
  4. <local:ImageButton x:Name="btn_jiaojia" Margin="5,0" ImgPath="/Images/脚架.png"  Width="82" Height="43" Template="{StaticResource ImageButtonTemplate}" Click="btn_jiaojia_Click" />
  5. <local:ImageButton x:Name="btn_xiangji" Margin="5,0" ImgPath="/Images/相机.png"  Width="82" Height="43" Template="{StaticResource ImageButtonTemplate}" Click="btn_xiangji_Click" />
  6. </StackPanel>
  7. <Popup x:Name="Pop_bg" PopupAnimation="Fade" Width="88" Height="125" PlacementTarget="{Binding ElementName=btn_bg}" Placement="Top" AllowsTransparency="True" StaysOpen="False" IsOpen="False">
  8. <Border>
  9. <Border.Background>
  10. <ImageBrush ImageSource="/AutoCamera;component/Images/下拉背景.png" />
  11. </Border.Background>
  12. <StackPanel Margin="5">
  13. <local:ImageButton Width="70" Height="31" ImgPath="/Images/上升.png" Margin="2,10" Template="{StaticResource ImageButtonTemplate}" />
  14. <local:ImageButton Width="70" Height="31" ImgPath="/Images/下降.png" Margin="2" Template="{StaticResource ImageButtonTemplate}" />
  15. </StackPanel>
  16. </Border>
  17. </Popup>
  18. <Popup x:Name="Pop_jiaojia" PopupAnimation="Fade" Width="88" Height="125" PlacementTarget="{Binding ElementName=btn_jiaojia}" Placement="Top" AllowsTransparency="True" StaysOpen="False" IsOpen="False">
  19. <Border>
  20. <Border.Background>
  21. <ImageBrush ImageSource="/AutoCamera;component/Images/下拉背景.png" />
  22. </Border.Background>
  23. <StackPanel Margin="5">
  24. <local:ImageButton Width="70" Height="31" ImgPath="/Images/上升.png" Margin="2" Template="{StaticResource ImageButtonTemplate}" />
  25. <local:ImageButton Width="70" Height="31" ImgPath="/Images/复位.png" Margin="2" Template="{StaticResource ImageButtonTemplate}" />
  26. <local:ImageButton Width="70" Height="31" ImgPath="/Images/下降.png" Margin="2" Template="{StaticResource ImageButtonTemplate}" />
  27. </StackPanel>
  28. </Border>
  29. </Popup>
  30. <Popup x:Name="Pop_xiangji" PopupAnimation="Fade" Width="88" Height="125" PlacementTarget="{Binding ElementName=btn_xiangji}" Placement="Top" AllowsTransparency="True" StaysOpen="False" IsOpen="False">
  31. <Border>
  32. <Border.Background>
  33. <ImageBrush ImageSource="/AutoCamera;component/Images/下拉背景.png" />
  34. </Border.Background>
  35. <StackPanel Margin="5">
  36. <local:ImageButton Width="70" Height="31" ImgPath="/Images/上升.png" Margin="2" Template="{StaticResource ImageButtonTemplate}" />
  37. <local:ImageButton Width="70" Height="31" ImgPath="/Images/复位.png" Margin="2" Template="{StaticResource ImageButtonTemplate}" />
  38. <local:ImageButton Width="70" Height="31" ImgPath="/Images/下降.png" Margin="2" Template="{StaticResource ImageButtonTemplate}" />
  39. </StackPanel>
  40. </Border>
  41. </Popup>

截图:
         


弹出菜单:

MyResDic.xaml

  1. <ControlTemplate x:Key="SelfMenuItemTemplate" TargetType="{x:Type MenuItem}">
  2. <Border Background="Transparent"  Height="25">
  3. <StackPanel Orientation="Horizontal">
  4. <Rectangle Width="5" Height="25" Name="mousemark" Fill="Gray" />
  5. <TextBlock Margin="5,0" VerticalAlignment="Center" Text="{Binding Header, RelativeSource={RelativeSource TemplatedParent}}"/>
  6. </StackPanel>
  7. </Border>
  8. <ControlTemplate.Triggers>
  9. <Trigger Property="IsMouseOver" Value="True">
  10. <Setter TargetName="mousemark" Property="Fill" Value="Blue" />
  11. </Trigger>
  12. </ControlTemplate.Triggers>
  13. </ControlTemplate>

MainWindow.xaml

  1. <local:ImageButton x:Name="btn_set" Width="27" Height="26" VerticalAlignment="Top"  ImgPath="/Images/设置菜单.png" Template="{StaticResource ImageButtonTemplate}" Click="btn_set_Click">
  2. <local:ImageButton.ContextMenu>
  3. <ContextMenu Name="menu" Placement="MousePoint" Width="200">
  4. <MenuItem Header="修改密码" Template="{StaticResource SelfMenuItemTemplate}" />
  5. <MenuItem Header="设置照片存放位置" Template="{StaticResource SelfMenuItemTemplate}" />
  6. <MenuItem Header="设置套系解析位置" Template="{StaticResource SelfMenuItemTemplate}" />
  7. <MenuItem Header="进入官网" Template="{StaticResource SelfMenuItemTemplate}" />
  8. <ContextMenu.Template>
  9. <ControlTemplate TargetType="{x:Type ContextMenu}">
  10. <Border Margin="10,10" Background="AliceBlue">
  11. <ItemsPresenter Margin="2,2" />
  12. <Border.Effect>
  13. <DropShadowEffect BlurRadius="8" Opacity="0.5" />
  14. </Border.Effect>
  15. </Border>
  16. </ControlTemplate>
  17. </ContextMenu.Template>
  18. </ContextMenu>
  19. </local:ImageButton.ContextMenu>
  20. </local:ImageButton>

截图:


下面给大家欣赏下整个界面好了,请允许我小小的嘚瑟下~



工程下载地址(只实现了界面哦~):
http://yun.baidu.com/share/link?shareid=1484254303&uk=3508115909

WPF自定义Popup和弹出菜单的更多相关文章

  1. WPF 左键单击弹出菜单 ContextMenu

    原文:WPF 左键单击弹出菜单 ContextMenu WPF中的ContextMenu在XAML中可直接做出来,但是仅限于右键弹出菜单,如果需要添加左键弹出功能,只需要在事件中添加Click事件 X ...

  2. [译]GLUT教程 - 弹出菜单基础

    Lighthouse3d.com >> GLUT Tutorial >> Pop-up Menus >> Popup Menus 弹出菜单也是GLUT的一部分.虽然 ...

  3. PopupWindow(2)简单示例-自定义弹出菜单

    本示例,用 popupWindow 自定义弹出菜单 public class CustomActionProvider extends ActionProvider implements OnMenu ...

  4. WPF 之 左键弹出操作菜单,并禁用右键菜单

    在目前的WPF版本中,很多的控件都有一个ContextMenu的属性,可以设置组件的右键菜单,这点确实是很方便,但是有些时候我们可能会需要当单击鼠标左键才弹出这个ContextMenu,而不是单击鼠标 ...

  5. 用PopupWindow实现弹出菜单(弹出的菜单采用自定义布局)

         用PopupWindow实现弹出菜单是一个比较好的方式.当然我们还有一个类PopupMenu也能实现弹出菜单,但那个太过于局限了,所以不是很推荐. 这个实例的效果是这样的:点击按钮后,一个菜 ...

  6. 【Android】5.6 弹出菜单(PopUp Menus)

    分类:C#.Android.VS2015: 创建日期:2016-02-07 一.简介 功能描述:用户单击按钮弹出菜单.当用户选择一个菜单项,会触发MenuItemClick事件并让弹出的菜单消失:如果 ...

  7. 向上弹出菜单jQuery插件

    插件名:柯乐义英文名:Keleyijs文件名称:jquery.keleyi.js插件功能:该插件可以让你轻易地在页面上构建一个向上弹出的二级菜单. 示例查看:http://keleyi.com/kel ...

  8. [Flex] PopUpButton系列 —— 弹出菜单的行高设置

    <?xml version="1.0" encoding="utf-8"?> <!--Flex中如何通过variableRowHeight样式 ...

  9. [Flex] PopUpButton系列 —— 控制弹出菜单的透明度、可用、可选择状态

    <?xml version="1.0" encoding="utf-8"?><!--控制弹出菜单的透明度.可用.可选择状态 PopUpButt ...

随机推荐

  1. uva 11732 (trie树)

    题意:求N个字符串两两比较,共比较了多少次? #include<iostream> #include<cstring> #include<cstdio> using ...

  2. 同余方程(codevs 1200)

    题目描述 Description 求关于 x 同余方程 ax ≡ 1 (mod b)的最小正整数解. 输入描述 Input Description 输入只有一行,包含两个正整数 a, b,用 一个 空 ...

  3. math对象的方法

    方法 描述 abs(x) 返回数的绝对值. acos(x) 返回数的反余弦值. asin(x) 返回数的反正弦值. atan(x) 以介于 -PI/2 与 PI/2 弧度之间的数值来返回 x 的反正切 ...

  4. 转 廖雪峰 urllib

    http://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/001432688314740a0 ...

  5. EXT.JS以下两种写法在初始载入时是一样的效果

    /* Ext.application({ name: 'MyfirstApplication', launch: function () { Ext.Msg.alert("Hello&quo ...

  6. SqlHelper类-全面

    // ===============================================================================// Microsoft Data ...

  7. linux下kill某个应用

    linux命令行与桌面切换快捷键Ctr+Alt+F1,Ctr+Alt+F7 ps -e | grep abc sudo kill xyz

  8. [Violet 4] 毕业旅行

    2718: [Violet 4]毕业旅行 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 672  Solved: 389[Submit][Status ...

  9. Netty学习_Netty框架入门教程:Netty入门之HelloWorld实现

    我们可能都学过Socket通信/io/nio/aio等的编程.如果想把Socket真正的用于实际工作中去,那么还需要不断的完善.扩展和优化.比如很经典的Tcp读包写包问题,或者是数据接收的大小,实际的 ...

  10. 使用一个数组存储一个英文句子"java is an object oriented programing language"

    class fun { public static void main(String[] args) { String str="java is an object oriented pro ...