C# ScrollViewer项目在Windows 8上不同

C# ScrollViewer项目在Windows 8上不同,c#,.net,wpf,windows-8,C#,.net,Wpf,Windows 8,当我在Windows8上运行我的程序时,ScrollViewer中的项目在所有边上都有额外的边距,在某些列表框中,项目背景丢失,并且还有不吸引人的项目高亮显示。我可以强制它像在Windows7上一样渲染吗 添加到每个 <setter Property="FocusVisualStyle" Value="{x:Null}"/> <setter Property="ListBoxItem.BorderThickness" Value="0"/> 似乎可以解决问题,但

当我在Windows8上运行我的程序时,ScrollViewer中的项目在所有边上都有额外的边距,在某些列表框中,项目背景丢失,并且还有不吸引人的项目高亮显示。我可以强制它像在Windows7上一样渲染吗

添加到每个

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


似乎可以解决问题,但在Windows 8上,背景仍有高亮度,WPF的默认系统主题与Windows 7中的旧Aero主题不同。我认为Windows 8主题与旧Aero主题并存,因此您可以尝试在启动时将Aero资产注入应用程序:

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
items)。

谢谢。我将为Windows8重新设计一切,因为在Windows8中使用Aero是没有意义的。