There is an old Winforms control which I hosted in WPF app.
Control makes use of System.Windows.Forms.ListView
inside and this ListView uses Groups feature.
The problem is that this control when hosted by WPF does not show groups.
I've manually compared properties of ListView when it's hosted by Winforms app and WPF app.
For both ListViews ShowGroups
property is true.
However there is a property called GroupsEnabled
and it's true when control is hosted in Winforms and false when it's hosted in WPF.
I've found definition here:
internal bool GroupsEnabled
{
get {
return this.ShowGroups && groups != null && groups.Count > 0 && ComctlSupportsVisualStyles && !VirtualMode;
}
}
VirtualMode
is false for both but ComctlSupportsVisualStyles
is true for Winforms hosting and false for WPF app.
Code of ComctlSupportsVisualStyles
from the same source:
private bool ComctlSupportsVisualStyles {
get {
if(!listViewState[LISTVIEWSTATE_comctlSupportsVisualStylesTested])
{
listViewState[LISTVIEWSTATE_comctlSupportsVisualStylesTested] = true;
listViewState[LISTVIEWSTATE_comctlSupportsVisualStyles] = Application.ComCtlSupportsVisualStyles;
}
return listViewState[LISTVIEWSTATE_comctlSupportsVisualStyles];
}
}
I think I need to set Application.ComCtlSupportsVisualStyles
somehow in my WPF code.
And this must be System.Windows.Forms.Application
and not System.Windows.Application
.
Is there any way to do it?