<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Shared.xaml" />
</ResourceDictionary.MergedDictionaries> <!--<SnippetListBox>-->
<Style x:Key="{x:Type ListBox}"
TargetType="ListBox">
<Setter Property="SnapsToDevicePixels"
Value="true" />
<Setter Property="OverridesDefaultStyle"
Value="true" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility"
Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility"
Value="Auto" />
<Setter Property="ScrollViewer.CanContentScroll"
Value="true" />
<Setter Property="MinWidth"
Value="" />
<Setter Property="MinHeight"
Value="" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<Border Name="Border"
BorderThickness=""
CornerRadius="">
<Border.Background>
<SolidColorBrush Color="{StaticResource ControlLightColor}" />
</Border.Background>
<Border.BorderBrush>
<SolidColorBrush Color="{StaticResource BorderMediumColor}" />
</Border.BorderBrush>
<ScrollViewer Margin=""
Focusable="false">
<StackPanel Margin=""
IsItemsHost="True" />
</ScrollViewer>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled"
Value="false">
<Setter TargetName="Border"
Property="Background">
<Setter.Value>
<SolidColorBrush Color="{StaticResource DisabledControlLightColor}" />
</Setter.Value>
</Setter>
<Setter TargetName="Border"
Property="BorderBrush">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource DisabledBorderLightColor}" />
</Setter.Value> </Setter>
</Trigger>
<Trigger Property="IsGrouping"
Value="true">
<Setter Property="ScrollViewer.CanContentScroll"
Value="false" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> <Style x:Key="{x:Type ListBoxItem}"
TargetType="ListBoxItem">
<Setter Property="SnapsToDevicePixels"
Value="true" />
<Setter Property="OverridesDefaultStyle"
Value="true" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border x:Name="Border"
Padding=""
SnapsToDevicePixels="true">
<Border.Background>
<SolidColorBrush Color="Transparent" />
</Border.Background>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected" />
<VisualState x:Name="Selected">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Border"
Storyboard.TargetProperty="(Panel.Background).
(SolidColorBrush.Color)">
<EasingColorKeyFrame KeyTime=""
Value="{StaticResource SelectedBackgroundColor}" />
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="SelectedUnfocused">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Border"
Storyboard.TargetProperty="(Panel.Background).
(SolidColorBrush.Color)">
<EasingColorKeyFrame KeyTime=""
Value="{StaticResource SelectedUnfocusedColor}" />
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentPresenter />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--</SnippetListBox>-->
</ResourceDictionary>

ControlTemplate in WPF —— ListBox的更多相关文章

  1. WPF : ListBox的几种Template属性

    原文:WPF : ListBox的几种Template属性 属性名 属性的类名 功能 示例 Template ControlTemplate 定义控件自身的外观.其子元素的布局可以自定义,也可以由It ...

  2. 自定义WPF ListBox的选择样式

    (下图:进行多项选择的ListBox) 首先介绍一种简单地方法:就是通过自定义SystemColors类的参数来自定义WPF ListBox选择颜色的,SystemColors的HighlightBr ...

  3. WPF ListBox 横向排列

    WPF ListBox 横向排列   如果只是单纯的让ListBox可以横向配列,这样很简单,只需要更改ListBox的ItemsPanel模板就可以,例如: <ListBox><L ...

  4. 自定义WPF ListBox的选中项样式

    首先介绍一种简单地方法:就是通过自定义SystemColors类的参数来自定义WPF ListBox选择颜色的,SystemColors的HighlightBrushKey和HighlightText ...

  5. WPF ListBox数据绑定

    本文来源 http://wshoufeng1989.blog.163.com/blog/static/202047033201282911633670/  风随影动的博客 使用数据库AllData , ...

  6. wpf listbox 选中项 上移下移

    原文:wpf listbox 选中项 上移下移 private void MoveUp_Click(object sender, RoutedEventArgs e)         {        ...

  7. WPF ListBox ItemContainerStyle 设置BackGround 和 BorderBrush 无效

    今天更改ListBox,用到ItemContainerStyle设置样式,设置Style.Triggers时,BackGround和BorderBrush均无效,其他效果正常. 翻看WPF编程宝典,发 ...

  8. WPF ListBox

    记录一些ListBox的用法 设置ListBox选中项的背景颜色 如何为标准的ListBox添加ItemClick事件 连续选择同一项时SelectionChanged 事件不响应的问题 1.设置Li ...

  9. wpf listbox 内的内容显示问题,需要设置里面的itemsPresenter

    有时候控件并非维护本身逻辑,而是依赖于父子元素的,如了上诉的ContentPresenter,我们还有一个非常常用的ListBox控件,因为继承自ItemsControl,所以有一个ItemsPane ...

随机推荐

  1. poj 1953 World Cup Noise (dp)

    World Cup Noise Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16774   Accepted: 8243 ...

  2. Linux中FTP服务器配置

         1.FTP服务器的一些基本概念       (1)FTP连接方式     控制连接:标准端口为21,用于发送FTP命令信息.     数据连接:标准端口为20,用于上传.下载数据.      ...

  3. A RECURRENT NEURAL NETWORK WITHOUT CHAOS

    本篇文章的介绍了一个非常简单的门限RNN(gated recurrent neural network), 这里有两扇门horizontal/forget gate和vertical/input ga ...

  4. 牛客第八场 C-counting paths 树形dp计数

    题目地址 题意 给你一颗树 初始点颜色全部为白色 对于每一个满足要求一的点集s f(s)的定义为先把点集内的点染黑 满足要求二的路径集合数量 要求一为两两黑点之间不能出现白色的点 要求二为将这个路径集 ...

  5. JavaScript This 的六道坎

    鉴于this风骚的运作方式,对this的理解是永不过时的话题,本文试图通过将其大卸六块来钉住这个磨人的妖精. 首先 this is all about context. this说白了就是找大佬,找拥 ...

  6. maven生成jar包编码问题

    要做一个jar文件供外部调用,此jar的源代码中注释为中文,用maven打包后在其它工程中导入后总不能正常显示中文,记录解决方法如下: 在pom.xml中设置默认编码类型为UTF-8: <pro ...

  7. Django框架简介(1)

    目录 手写web框架 基于wsgiref模块写web服务端框架 python三大主流框架 django框架介绍 注意事项 django下载方法 django项目及app的创建 命令行创建项目 pych ...

  8. ORACLE获取BOM清单

    BOM 结构如图 -- 1DH142-022 (DRIVE) -- 100729421  (PCBA) -- 100764148  (HDA) -- 100687050 (VCM) -- 100701 ...

  9. 创建本地repo源

    1,保留rpm包 yum 安装时保留包至指定目录 编辑/etc/yum.conf 将keepcache的值设置为1: 2,使用插件 1,yum-plugin-downloadonly插件 sudo y ...

  10. springboot运行jar包时候加载指定目录的其他jar支持包

    最近发生一个小故障,调试好的项目,发布成jar包后无法找到oracle的驱动,研究了一下解决了.记录一下.写了一个run.sh脚本 #!/bin/bash cd ~ cd app nohup java ...