Datatemplates when using theme not working - WPF

I am using the DarkExpression theme from WPF Futures . This does not seem to work with datatemplates.

Scenario 1:

Here's what it looks like without datatemplates:

enter image description here

the code:

<ListView Name="playlistListView"  ItemsSource="{Binding PlaylistList}" Margin="0" SelectionChanged="DatabindedPlaylistListView_SelectionChanged" Background="{x:Null}" Opacity="0.98">
        <ListView.View>
            <GridView>
                <GridViewColumn Width="Auto" DisplayMemberBinding="{Binding Name}">
                    <GridViewColumnHeader HorizontalContentAlignment="Left" Content="Playlist" Tag="Playlist"/>
                </GridViewColumn>
            </GridView>
        </ListView.View>
</ListView>

Scenario 2: Here's what it looks like when trying to use datatemplates when using a theme:

enter image description here

the code:

        <ListView Name="playlistListView"  ItemsSource="{Binding PlaylistList}" Margin="0" SelectionChanged="DatabindedPlaylistListView_SelectionChanged" Background="{x:Null}" Opacity="0.98">
        <ListView.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <UserControls:SongDataTemplate Margin="4" />
                </Grid>
            </DataTemplate>
        </ListView.ItemTemplate>
</ListView>

Scenario 3:

Here's what it looks like when trying to use datatemplates when redefining a theme:

enter image description here

the code:

<UserControl.Resources>
    <Style x:Key="ListViewItemStretch" TargetType="{x:Type ListViewItem}">
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="Background" Value="Transparent" />
    </Style>
</UserControl.Resources>

<Grid x:Name="LayoutRoot">
    <ListView Name="playlistListView" ItemContainerStyle="{StaticResource ListViewItemStretch}" ItemsSource="{Binding PlaylistList}" Margin="0" SelectionChanged="DatabindedPlaylistListView_SelectionChanged" Background="{x:Null}" Opacity="0.98">
        <ListView.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <UserControls:SongDataTemplate Margin="4" />
                </Grid>
            </DataTemplate>
        </ListView.ItemTemplate>
</ListView>

I want to keep the theme style, but I also want to use datatemplates to determine what the playlist should look like. Any suggestions?

Note: In scenarios 2 and 3, I had to delete

<ListView.View>
        <GridView>
            <GridViewColumn Width="Auto" DisplayMemberBinding="{Binding Name}">
                <GridViewColumnHeader HorizontalContentAlignment="Left" Content="Playlist" Tag="Playlist"/>
            </GridViewColumn>
        </GridView>
</ListView.View>

Before using datatemplate.

Edit:

, , , ListBox, TextBox. ListView.

+1
3

. ListView, , ViewBase. ViewBase, ListView.View, . ViewBase

+1

BasedOn

<Style BasedOn={StaticResource {x:Type ListViewItem}} x:Key="ListViewItemStretch" TargetType="{x:Type ListViewItem}"> 
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/> 
    <Setter Property="Background" Value="Transparent" /> 
</Style>
+1

,

<Grid>
   <UserControls:SongDataTemplate Margin="4" />
</Grid>

TextBox, ?

.

0

Source: https://habr.com/ru/post/1740685/


All Articles