Datatemplates while using theme does not work - WPF

Posted by bobjink on Stack Overflow See other posts from Stack Overflow or by bobjink
Published on 2010-04-07T14:00:37Z Indexed on 2010/04/07 14:03 UTC
Read the original article Hit count: 811

Filed under:
|
|
|

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

Scenario 1:

Here is how it looks like without datatemplates: Pic 1

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 is how it looks like trying to use datatemplates while using the theme: Pic 2

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 is how it looks like trying to use datatemplates while overriding the theme: Pic3

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 define how a playlist should look like. Any suggestions?

Note: In scenario 2 and 3 I had to remove

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

Before the datatemplate would be used.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about datatemplate