Question

I have an application I'm developing which closely mirrors Windows 7's Device Stage. In Device Stage, beneath the main banner there is a ListView containing actions embodied as ListViewItems.

In my WPF application, I used WindowsFormsHost to host a WinForms ListView so that I could use SetWindowTheme() on it and apply Windows Vista/7 styling to it.

This, however, does not work and doesn't achieve the same effect it does when used in Windows Forms.

How can I achieve the Windows 7 look on a ListView in WPF? I'm not looking to create a custom style then apply it because frankly that's too much of a pain in the ass to continue using WPF for this app.

Thanks! :)

Was it helpful?

Solution

Just add the following lines:

[DllImport("uxtheme.dll", CharSet = CharSet.Unicode)] 
public static extern int SetWindowTheme(IntPtr hWnd, String pszSubAppName, String pszSubIdList); 

.ctor 
{
    System.Windows.Forms.Integration.WindowsFormsHost.EnableWindowsFormsInterop();
    System.Windows.Forms.Application.EnableVisualStyles();

    SetWindowTheme(MyControl.Handle, "Explorer", null); 
}

OTHER TIPS

Apparently after digging around, the only answer does indeed appear to be creating a custom-designed control in WPF.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top