4
Vote

ListViewItem Height Bug

description

When I apply the wpf theme to a list view the list view item height appears collapsed. XAML as follows:
 
<UserControl x:Class="StrategiesModule.Views.StrategiesNavigationBarView.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="ShinyBlue.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</UserControl.Resources>
<StackPanel>
    <ListView>
        <ListViewItem Content="1" />
    </ListView>
</StackPanel>
</UserControl>

comments

damdamo wrote Jun 1, 2011 at 9:36 AM

In my opinion <ContentPresenter/> is missing in ListViewItem control template.
Solution:
Open proper theme and find: <ControlTemplate TargetType="{x:Type ListViewItem}">
In <Border> element add <ContentPresenter/> element after last <Rectangle >
Final xaml should look something like this:
<Rectangle x:Name="SelectedHoverRectangle"
                            IsHitTestVisible="False"
                            Fill="{StaticResource HoverBrush}"
                            RadiusX="0"
                            Opacity="0"/>
                        <ContentPresenter/>

wrote Feb 22, 2013 at 12:09 AM