编辑:这是本主题的继续:禁用选定的Listview项目2的蓝色边框
我想在Windows8.1的应用程序中这样做:
<ListView x:Name="gui_listView" HorizontalAlignment="Left"
Height="610" Margin="48,54,0,0" VerticalAlignment="Top"
Width="256" SelectionChanged="gui_listView_SelectionChanged"
SelectionMode="Extended">
<ListView.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="Transparent"/>
</ListView.Resources>
</ListView>
但是微软可能停止了对静态扩展的支持,有人知道我现在应该做什么吗?有错误的图片,我得到了什么。http://imagizer.imageshack.us/a/img835/4764/jlcc9.jpg
谢谢你的回应。
发布于 2014-05-19 21:44:25
既然你在问题中问了两个问题,我会给出两个答案。若要移除鼠标过度效果,您需要重写主题值。您可以在app.xaml中这样做。
<Application
x:Class="App41.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App41">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="ListViewItemPointerOverBackgroundThemeBrush" Color="Transparent" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
下面是嵌入在样式本身中的整个列表:
<ListViewItemPresenter
CheckHintBrush="{ThemeResource ListViewItemCheckHintThemeBrush}"
CheckBrush="{ThemeResource ListViewItemCheckThemeBrush}"
ContentMargin="4"
ContentTransitions="{TemplateBinding ContentTransitions}"
CheckSelectingBrush="{ThemeResource ListViewItemCheckSelectingThemeBrush}"
DragForeground="{ThemeResource ListViewItemDragForegroundThemeBrush}"
DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}"
DragBackground="{ThemeResource ListViewItemDragBackgroundThemeBrush}"
DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}"
FocusBorderBrush="{ThemeResource ListViewItemFocusBorderThemeBrush}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Padding="{TemplateBinding Padding}" PointerOverBackgroundMargin="1"
PlaceholderBackground="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}"
PointerOverBackground="{ThemeResource ListViewItemPointerOverBackgroundThemeBrush}"
ReorderHintOffset="{ThemeResource ListViewItemReorderHintThemeOffset}"
SelectedPointerOverBorderBrush="{ThemeResource ListViewItemSelectedPointerOverBorderThemeBrush}"
SelectionCheckMarkVisualEnabled="True"
SelectedForeground="{ThemeResource ListViewItemSelectedForegroundThemeBrush}"
SelectedPointerOverBackground="{ThemeResource ListViewItemSelectedPointerOverBackgroundThemeBrush}"
SelectedBorderThickness="{ThemeResource ListViewItemCompactSelectedBorderThemeThickness}"
SelectedBackground="{ThemeResource ListViewItemSelectedBackgroundThemeBrush}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
祝你好运!
发布于 2014-05-19 21:21:37
事实上,x:Static
并没有停止工作,它从未在Windows中工作过。所有绑定都是针对Windows运行时中的实例对象。我意识到这和WPF完全不同。但事实就是如此,最简单的解决办法是将静态引用封装在视图模型中。
public static class Information
{
public static string Secret = "8675309";
}
public class MyViewModel
{
public string Secret { get { return Information.Secret; } }
}
祝你好运!
发布于 2014-05-15 12:32:38
试试这个:
MSDN ListView样式
将其放入您的Window
或UC
Resources
标记中。
现在找到负责高亮显示的VisualState
,并根据您的喜好更改它。
HTH
我之所以没有发布现成的解决方案,是因为你会从找出哪个部分负责突出显示中获益更多,这将使开发变得更容易。
https://stackoverflow.com/questions/23674526
复制相似问题