Metro中listbox点击后整个背景不变色
来源:互联网 发布:达拉斯2000年人口数据 编辑:程序博客网 时间:2024/06/07 02:49
只需在 App.xaml 中更新画笔ListBoxFocusBackgroundThemeBrush
<SolidColorBrush x:Key="ListBoxFocusBackgroundThemeBrush" Color="Transparent" />
以下为metro样式的补充
metro UI控件系统样式文件位置,这里可以找到所有控件的系统样式
C:\Program Files (x86)\Windows Kits\8.0\Include\WinRT\Xaml\Design\generic.xaml
metro ListBox官方文档如下
ListBox 样式和模板
本主题介绍 ListBox 控件的样式和模板。 你可以修改这些资源和默认 ControlTemplate 以便为该控件提供一个唯一的外观。
视觉状态
这些状态是在该控件的默认样式中定义的 VisualState。
Normal
CommonStates
默认状态。Disabled
CommonStates
禁用控件。Focused
FocusStates
控件具有焦点。Unfocused
FocusStates
控件没有焦点。
有关焦点状态的详细信息,请参阅 Control.FocusState。
主题资源
这些资源在该控件的默认样式中使用。
深色主题画笔
若要在深色主题下更改该控件的颜色,请在 App.xaml 中替代这些画笔。
XAML
<SolidColorBrush x:Key="ListBoxBackgroundThemeBrush" Color="#CCFFFFFF" /><SolidColorBrush x:Key="ListBoxBorderThemeBrush" Color="Transparent" /><SolidColorBrush x:Key="ListBoxDisabledForegroundThemeBrush" Color="#66FFFFFF" /> <SolidColorBrush x:Key="ListBoxFocusBackgroundThemeBrush" Color="#FFFFFFFF" /><SolidColorBrush x:Key="ListBoxForegroundThemeBrush" Color="#FF000000" />
浅色主题画笔
若要在浅色主题下更改该控件的颜色,请在 App.xaml 中替代这些画笔。
XAML
<SolidColorBrush x:Key="ListBoxBackgroundThemeBrush" Color="#CCFFFFFF" /><SolidColorBrush x:Key="ListBoxBorderThemeBrush" Color="#45000000" /><SolidColorBrush x:Key="ListBoxDisabledForegroundThemeBrush" Color="#66000000" /><SolidColorBrush x:Key="ListBoxFocusBackgroundThemeBrush" Color="#FFFFFFFF" /><SolidColorBrush x:Key="ListBoxForegroundThemeBrush" Color="#FF000000" />
其他资源
XAML
<Thickness x:Key="ListBoxBorderThemeThickness">2</Thickness>
共享资源
该控件模板使用这些资源与其他控件模板共享。更改这些值将影响使用这些资源的其他控件。
XAML
<FontFamily x:Key="ContentControlThemeFontFamily">Segoe UI</FontFamily><x:Double x:Key="ControlContentThemeFontSize">14.667</x:Double>
默认样式
XAML
<!-- Default style for Windows.UI.Xaml.Controls.ListBox --><Style TargetType="ListBox"> <Setter Property="Foreground" Value="{StaticResource ListBoxForegroundThemeBrush}" /> <Setter Property="Background" Value="{StaticResource ListBoxBackgroundThemeBrush}" /> <Setter Property="BorderBrush" Value="{StaticResource ListBoxBorderThemeBrush}" /> <Setter Property="BorderThickness" Value="{StaticResource ListBoxBorderThemeThickness}" /> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /> <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" /> <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Disabled" /> <Setter Property="ScrollViewer.IsHorizontalRailEnabled" Value="True" /> <Setter Property="ScrollViewer.VerticalScrollMode" Value="Enabled" /> <Setter Property="ScrollViewer.IsVerticalRailEnabled" Value="True" /> <Setter Property="ScrollViewer.ZoomMode" Value="Disabled" /> <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" /> <Setter Property="ScrollViewer.BringIntoViewOnFocusChange" Value="True" /> <Setter Property="IsTabStop" Value="False" /> <Setter Property="TabNavigation" Value="Once" /> <Setter Property="FontFamily" Value="{StaticResource ContentControlThemeFontFamily}" /> <Setter Property="FontSize" Value="{StaticResource ControlContentThemeFontSize}" /> <Setter Property="ItemsPanel"> <Setter.Value> <ItemsPanelTemplate> <VirtualizingStackPanel /> </ItemsPanelTemplate> </Setter.Value> </Setter> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ListBox"> <Border x:Name="LayoutRoot" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal" /> <VisualState x:Name="Disabled"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="Background"> <DiscreteObjectKeyFrame KeyTime="0" Value="Transparent" /> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="BorderBrush"> <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxDisabledForegroundThemeBrush}" /> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="FocusStates"> <VisualState x:Name="Focused"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="Background"> <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxFocusBackgroundThemeBrush}" /> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="Unfocused"/> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <ScrollViewer x:Name="ScrollViewer" Padding="{TemplateBinding Padding}" TabNavigation="{TemplateBinding TabNavigation}" HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}" IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}" ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" BringIntoViewOnFocusChange="{TemplateBinding ScrollViewer.BringIntoViewOnFocusChange}"> <ItemsPresenter /> </ScrollViewer> </Border> </ControlTemplate> </Setter.Value> </Setter></Style>
- Metro中listbox点击后整个背景不变色
- ListView点击item背景不变色
- Android ListView item 点击背景不变色
- html 中如何实现背景变色而字体不变色
- 改变 ListBox Item 被点击后的蓝色背景
- js 点击一个链接后变色,但在点击页面其它链接不变色(方法一)
- js 点击一个链接后变色,但在点击页面其它链接不变色(方法二)
- ListView点击后item的颜色不变色
- listview滑动背景变色,点击变色等
- 文字选中后背景变色
- android中listview点击item不变色的问题
- iOS客户端学习-UITableView中的分割线/UITableViewCell点击背景不变色
- a标签去下划线和点击前和点击后不变色行不行啊?
- a标签怎么去下划线以及实现点击前和点击后不变色
- 一个javascript 点击后变色
- js+css控制弹出小窗口之后,后整个页面背景图变色,并且不可操作,点击确定,页面跳转。。。
- 鼠标点击表格行背景变色
- 鼠标点击表格行背景变色
- top命令的Load average 含义及性能参考基值
- 用VS2008打包应用程序为安装文件
- 重建二叉树
- Firefox OS 学习——Gaia settings源码分析(一)
- C语言深度解剖读书笔记(1.关键字的秘密)
- Metro中listbox点击后整个背景不变色
- Linux虚拟内存(VM)相关参数解析
- javascript深入理解js闭包
- Neumann boundary条件的实现
- UIButton使用介绍
- 重新验证先前的假设和评估风险的机会
- VS2010程序打包操作(超详细的)
- 十道海量数据处理面试题与十个方法大总结
- Eclipse 编辑xml文件时,没有提示