Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toolkit:Themes.UseVsTheme breaks gridview header #397

Open
JGT90 opened this issue Dec 6, 2022 · 2 comments
Open

toolkit:Themes.UseVsTheme breaks gridview header #397

JGT90 opened this issue Dec 6, 2022 · 2 comments

Comments

@JGT90
Copy link

JGT90 commented Dec 6, 2022

I am using a VSIX and wanted to test a GridView inside a ListView. But whenever I did it the header of the gridview was missing.

xmlns:toolkit="clr-namespace:Community.VisualStudio.Toolkit;assembly=Community.VisualStudio.Toolkit"
toolkit:Themes.UseVsTheme="True"
<Grid Grid.Row="1">
    <ListView ItemsSource="{Binding Persons}">
        <ListView.View>
            <GridView>
                <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}"/>
                <GridViewColumn Header="LastName" DisplayMemberBinding="{Binding LastName}"/>
                <GridViewColumn Header="ID" DisplayMemberBinding="{Binding ID}"/>
            </GridView>
        </ListView.View>
    </ListView>
</Grid>

image

After hours of debugging I finally stumbled across the toolkit:Themes.UseVsTheme. When I removed it, everything went fine. The header was displayed again.

xmlns:toolkit="clr-namespace:Community.VisualStudio.Toolkit;assembly=Community.VisualStudio.Toolkit"

toolkit:Themes.UseVsTheme="True"

<Grid Grid.Row="1">
    <ListView ItemsSource="{Binding Persons}">
        <ListView.View>
            <GridView>
                <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}"/>
                <GridViewColumn Header="LastName" DisplayMemberBinding="{Binding LastName}"/>
                <GridViewColumn Header="ID" DisplayMemberBinding="{Binding ID}"/>
            </GridView>
        </ListView.View>
    </ListView>
</Grid>

image

@JGT90 JGT90 changed the title toolkit:Themes.UseVsThem breaks gridview header toolkit:Themes.UseVsTheme breaks gridview header Dec 6, 2022
@reduckted
Copy link
Contributor

This is caused by the Microsoft.VisualStudio.PlatformUI.ThemedDialogStyleLoader.UseDefaultThemedDialogStyles attached property (which the UseVsTheme property internally sets enables). If you don't use Themes.UseVsTheme and instead set the UseDefaultThemedDialogStyles directly, you'll see the same problem:

<ListView 
    xmlns:platform="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.15.0"
    platform:ThemedDialogStyleLoader.UseDefaultThemedDialogStyles="True">
</ListView>

I guess an internal Visual Studio style is removing the headers for a reason.

Unfortunately setting that attached property to false on the ListView doesn't have any effect when something above it has already enabled the default themed dialog styles (enabling the themed dialog styles causes a resource dictionary to be loaded so it applies to that element and all descendants).

I think the only option is to redefine the ControlTemplate for the ListView so that it has a header.

@RobertvanderHulst
Copy link
Contributor

I am having the same problem. Dave, do you have an example how to redefine the ControlTemplate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants