首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >做x:静态扩展工作在WinRT-XAML?

做x:静态扩展工作在WinRT-XAML?
EN

Stack Overflow用户
提问于 2014-05-15 09:39:44
回答 3查看 670关注 0票数 1

编辑:这是本主题的继续:禁用选定的Listview项目2的蓝色边框

我想在Windows8.1的应用程序中这样做:

代码语言:javascript
运行
复制
<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

谢谢你的回应。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-05-19 21:44:25

既然你在问题中问了两个问题,我会给出两个答案。若要移除鼠标过度效果,您需要重写主题值。您可以在app.xaml中这样做。

代码语言:javascript
运行
复制
<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>

下面是嵌入在样式本身中的整个列表:

代码语言:javascript
运行
复制
<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}"/>

祝你好运!

票数 0
EN

Stack Overflow用户

发布于 2014-05-19 21:21:37

事实上,x:Static并没有停止工作,它从未在Windows中工作过。所有绑定都是针对Windows运行时中的实例对象。我意识到这和WPF完全不同。但事实就是如此,最简单的解决办法是将静态引用封装在视图模型中。

代码语言:javascript
运行
复制
public static class Information
{
    public static string Secret = "8675309";
}

public class MyViewModel 
{
    public string Secret { get { return Information.Secret; } }
}

祝你好运!

票数 1
EN

Stack Overflow用户

发布于 2014-05-15 12:32:38

试试这个:

MSDN ListView样式

将其放入您的WindowUC Resources标记中。

现在找到负责高亮显示的VisualState,并根据您的喜好更改它。

HTH

我之所以没有发布现成的解决方案,是因为你会从找出哪个部分负责突出显示中获益更多,这将使开发变得更容易。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23674526

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档