c# - Windows 8 上的 ScrollViewer 项目不同

标签 c# .net wpf windows-8

当我在 Windows 8 上运行我的程序时,ScrollViewer 中的项目在所有边上都有额外的边距,在某些 ListBox-es 上项目背景丢失并且还有不吸引人的项目突出显示。我可以强制它像在 Windows 7 上一样呈现吗?

添加到每个

<setter Property="FocusVisualStyle" Value="{x:Null}"/> 
<setter Property="ListBoxItem.BorderThickness" Value="0"/> 

似乎解决了问题,但背景仍然高亮

最佳答案

在 Windows 8 上,WPF 的默认系统主题与 Windows 7 中的旧 Aero 主题不同。我认为 Windows 8 主题与旧 Aero 主题并存,因此您可以尝试注入(inject)在启动时将 Aero Assets 添加到您的应用程序中:

try
{
    var uri = new Uri(
        "PresentationFramework.Aero;component\\themes/aero.normalcolor.xaml", 
        UriKind.Relative);

    var aeroResources = Application.LoadComponent(uri) as ResourceDictionary;
    if (aeroResources != null)
        Application.Current.Resources.MergedDictionaries.Add(aeroResources);
}
catch
{
    //
    // Proceed with the current theme.
    //
}

请注意,这将使您的整个应用程序显示为它在 Windows 7 下的样子(而不仅仅是 ListBox 项)。

关于c# - Windows 8 上的 ScrollViewer 项目不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21289490/

相关文章:

c# - 在 Azure 云服务中获取 x509 证书

c# - "does not contain a definition...and no extension method.."错误

c# stdin read没有响应

c# - 报表查看器可以从表单传递图像吗?

c# - 如何将一个类标记为已弃用?

c# - 如何将此 WPF 控件添加到我的 WinForm 中?

c# - 制作用户控制脉冲

c# - 转向 ASP.NET - VB 还是 C#?

c# - String 对象如何在没有 new 关键字或构造函数的情况下分配内存?

c# - ASP.NET MVC Helpers,将两个对象 htmlAttributes 合并在一起