当我在 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/