WPF 自定义下拉列表
XAML代码:
<Popup x:Name="popupStrategy" StaysOpen="False" PopupAnimation="Scroll" Width="190" MaxHeight="300" AllowsTransparency="True">
<Border Background="#0c5ab0" BorderThickness="1" BorderBrush="#1992d6">
<ItemsControl x:Name="itemsCtrlStrategy" Grid.Row="1" Margin="0 5 0 0">
<ItemsControl.Template>
<ControlTemplate>
<ScrollViewer HorizontalScrollBarVisibility="Auto" MinHeight="{Binding ElementName=itemsCtrlStrategy,Path=ActualHeight}" MinWidth="{Binding ElementName=itemsCtrlStrategy, Path=ActualWidth}">
<ItemsPresenter></ItemsPresenter>
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="5 0 5 5" Background="#00234E">
<Button x:Name="btnStrategySel" Click="btnStrategySel_Click_1" CommandParameter="{Binding}" Width="120" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button.Template>
<ControlTemplate>
<TextBlock Text="{Binding Info.STRATEGYNAME}" ToolTip="{Binding Info.STRATEGYNAME}" Width="120" Foreground="#1ba4f6" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
</ControlTemplate>
</Button.Template>
</Button>
<Button x:Name="btnStrategyDel" Margin="5" CommandParameter="{Binding}" Click="btnStrategyDel_Click_1" Height="12" Width="12" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button.Template>
<ControlTemplate>
<Image Name="img" Width="12" Height="12" VerticalAlignment="Center" Source="/SunCreate.CombatPlatform.Client.Resources;component/Image/CaseExportStrategy/删除.png"></Image>
</ControlTemplate>
</Button.Template>
</Button>
<Button x:Name="btnStrategyEdit" Margin="5" CommandParameter="{Binding}" Click="btnStrategyEdit_Click_1" Height="12" Width="12" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button.Template>
<ControlTemplate>
<Image Name="img" Width="12" Height="12" VerticalAlignment="Center" Source="/SunCreate.CombatPlatform.Client.Resources;component/Image/CaseExportStrategy/编辑.png"></Image>
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border>
</Popup>
后台代码:
itemsCtrlStrategy.ItemsSource = strategyViewModelList; popupStrategy.PlacementTarget = sender as Button;
popupStrategy.Placement = PlacementMode.Bottom;
popupStrategy.IsOpen = true;
效果图:
WPF 自定义下拉列表的更多相关文章
- WPF 自定义柱状图 BarChart
WPF 自定义柱状图 当前的Telerik控件.DevExpress控件在图表控件方面做得不错,但是有时项目中需要特定的样式,不是只通过修改图表的模板和样式就能实现的. 或者说,通过修改当前的第三方控 ...
- wpf 自定义圆形按钮
wpf 自定义圆形按钮 效果图 默认样式 获取焦点样式 点击样式 下面是实现代码: 一个是自定义控件类,一个是控件类皮肤 using System; using System.Collections. ...
- WPF自定义窗口基类
WPF自定义窗口基类时,窗口基类只定义.cs文件,xaml文件不定义.继承自定义窗口的类xaml文件的根节点就不再是<Window>,而是自定义窗口类名(若自定义窗口与继承者不在同一个命名 ...
- WPF 自定义 MessageBox (相对完善版)
WPF 自定义 MessageBox (相对完善版) 基于WPF的自定义 MessageBox. 众所周知WPF界面美观.大多数WPF元素都可以简单的修改其样式,从而达到程序的风格统一.可是当 ...
- WPF自定义Window样式(2)
1. 引言 在上一篇中,介绍了如何建立自定义窗体.接下来,我们需要考虑将该自定义窗体基类放到类库中去,只有放到类库中,我们才能在其他地方去方便的引用该基类. 2. 创建类库 接上一篇的项目,先添加一个 ...
- WPF自定义Window样式(1)
1. 引言 WPF是制作界面的一大利器.最近在做一个项目,用的就是WPF.既然使用了WPF了,那么理所当然的,需要自定义窗体样式.所使用的代码是在网上查到的,遗憾的是,整理完毕后,再找那篇帖子却怎么也 ...
- WPF自学入门(九)WPF自定义窗口基类
今天简单记录一个知识点:WPF自定义窗口基类,常用winform的人知道,winform的窗体继承是很好用的,写一个基础窗体,直接在后台代码改写继承窗体名.但如果是WPF要继承窗体,我个人感觉没有理解 ...
- WPF自定义TabControl样式
WPF自定义TabControl,TabControl美化 XAML代码: <TabControl x:Class="SunCreate.Common.Controls.TabCont ...
- WPF 自定义ComboBox样式,自定义多选控件
原文:WPF 自定义ComboBox样式,自定义多选控件 一.ComboBox基本样式 ComboBox有两种状态,可编辑和不可编辑状态.通过设置IsEditable属性可以切换控件状态. 先看基本样 ...
随机推荐
- spring框架中工厂方法的创建和销毁
1.编写接口UserSerivce: public interface UserService { public void sayHello(); } 2.编写实实现接口的方法,在该方法中除了要实现接 ...
- 【深度好文】多线程之WaitHandle-->派生-》Mutex信号量构造
bool flag = false; System.Threading.Mutex mutex = new System.Threading.Mutex(true, "Test", ...
- git 一些提交等用法
从服务器上下载项目到em_cesium:git clone ssh://kjwang@code-bj.clustertech.com:29418/em-satdata em_cesium 在本地新建一 ...
- DNA拷贝数变异CNV检测——基础概念篇
DNA拷贝数变异CNV检测——基础概念篇 一.CNV 简介 拷贝数异常(copy number variations, CNVs)是属于基因组结构变异(structural variation), ...
- dumpbin 查看dll中的导出函数
C:\Program Files (x86)\Microsoft Visual Studio 14.0>dumpbin -exports E:\20171110\Release\aa.dll h ...
- 多线程的使用:只能用cmd来玩不能用idle
from multiprocessing import Process import os def pro_do(name, func): print () if __name__ == " ...
- seo工具
http://tool.seowhy.com/ 一.关键词查词类工具:可以查询出更多目标客户可能搜索的词语 1.百度指数:http://index.baidu.com/ 这个工具是使用人数最多的 2. ...
- SQLALchemy--ORM框架
SQLAlchemy 1.介绍 SQLAlchemy是一个基于Python实现的ORM框架.该框架建立在 DB API之上,使用关系对象映射进行数据库操作,简言之便是:将类和对象转换成SQL,然后使用 ...
- 2018.10.14 loj#6003. 「网络流 24 题」魔术球(最大流)
传送门 网络流好题. 这道题可以动态建图. 不难想到把每个球iii都拆点成i1i_1i1和i2i_2i2,每次连边(s,i1),(i2,t)(s,i_1),(i_2,t)(s,i1),(i2, ...
- 46 What Is Real Happiness ? 什么是真正的幸福 ?
46 What Is Real Happiness ? 什么是真正的幸福 ? ①The way people hold to the belief that a fun-filled, pain-fr ...