Open GiuseppeIII opened 2 years ago
I'm seeing the same thing. I added this to test the theory and then my GridView
columns displayed (obviously with the stylings missing).
<ListView.Style>
<Style TargetType="{x:Type ListView}"/>
</ListView.Style>
Just try to change that line to this
<GridViewRowPresenter/>
and it seems to work
(It's just that there aren't dividers of column)
<ListView Name="MemberListView"
ContextMenuOpening="MemberListView_ContextMenuOpening"
SelectionMode="Single">
<ListView.View>
<GridView>
<GridViewColumn Header="ID"
DisplayMemberBinding="{Binding ID}" />
<GridViewColumn Header="群角色"
DisplayMemberBinding="{Binding Role}" />
<GridViewColumn Header="昵称"
DisplayMemberBinding="{Binding Nickname}" />
<GridViewColumn Header="群名片"
DisplayMemberBinding="{Binding Card}" />
<GridViewColumn Header="游戏ID"
DisplayMemberBinding="{Binding GameID}" />
</GridView>
</ListView.View>
</ListView>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ui:ControlsDictionary />
<ui:ThemesDictionary Theme="Light" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="ListViewItem">
<Setter Property="Foreground">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource TextFillColorPrimary}" />
</Setter.Value>
</Setter>
<Setter Property="Background"
Value="Transparent" />
<Setter Property="BorderBrush">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource SystemAccentColorSecondary}" />
</Setter.Value>
</Setter>
<Setter Property="SnapsToDevicePixels"
Value="True" />
<!--<Setter Property="OverridesDefaultStyle" Value="True" />-->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border x:Name="Border"
Margin="0"
Padding="4"
Background="{TemplateBinding Background}"
BorderThickness="1"
CornerRadius="4">
<Border.BorderBrush>
<SolidColorBrush Opacity="0.0"
Color="{DynamicResource SystemAccentColorSecondary}" />
</Border.BorderBrush>
<GridViewRowPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected"
Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="Border"
Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Opacity)"
From="0.0"
To="1.0"
Duration="0:0:.16" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="Border"
Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Opacity)"
From="1.0"
To="0.0"
Duration="0:0:.16" />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
@Zaitonn Thank you for sharing. Your approach works for me in the short term. Again, thank you, it's much appreciated.
Styling for ListView causes GridViewColumn DisplayMemberBinding not to work.