编辑:这是此主题的继续:Disable blue border for selected Listview item 2
我想在适用于Windows 8.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
感谢您的回复。
答案 0 :(得分:1)
事实是x:Static
没有停止工作,它从未在Windows运行时工作。所有绑定都是Windows运行时中的实例对象。我意识到这绝对不同于WPF。但它就是这样,最简单的解决方法是在视图模型中包装静态引用。
public static class Information
{
public static string Secret = "8675309";
}
public class MyViewModel
{
public string Secret { get { return Information.Secret; } }
}
祝你好运!
答案 1 :(得分:0)
试试这个:
MSDN ListView styles
将其放在Window
或UC
Resources
标记中
现在找到负责突出显示的VisualState
并根据自己的喜好进行更改
HTH
附:之所以我没有发布现成的解决方案是因为你会从找出哪个部分负责突出显示中获益更多,这将使开发更容易。
答案 2 :(得分:0)
由于您在问题中提出两个问题,我将提供两个答案。要删除鼠标悬停效果,您需要覆盖主题值。您可以在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}"/>
祝你好运!