2

When I run my program on Windows 8, items in ScrollViewer have additional margins on all sides, on some ListBox-es item background is missing and there is also unappealing item highlighting. Can I force it to render exactly like on Windows 7?

Adding to each

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

seems to fix the problem but background still has hightlighting

1 Answer 1

0

On Windows 8, the default system theme for WPF is different than the old Aero theme from Windows 7. I think the Windows 8 theme exists alongside the old Aero theme, so you could try injecting the Aero assets into your application on startup:

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.
    //
}

Note that this will make your entire application appear as it does under Windows 7 (not just ListBox items).

1
  • Thanks. I will restyle everything for Windows 8 since it would not make sense to use Aero in Windows 8.
    – Daniel
    Jan 23, 2014 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.