首页 新闻 会员 周边 捐助

ListView第一项内容消失

0
悬赏园豆:10 [已关闭问题] 关闭于 2015-08-14 16:29

我给ListView.ItemsTemplate.DataTemplate里的Grid设置宽度,结果发现第一项不见了。不设置宽度,正常显示。

 <DataTemplate x:Key="GridViewKnowledgeSystemDiagramDataTemplateForPhone">
        <Grid Height="40" VerticalAlignment="Center" HorizontalAlignment="Stretch" Width="{Binding ElementName=ListViewKnowledgeSystemDiagram,Path=ItemsPanelRoot.ActualWidth,Mode=OneWay}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="40"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Image Source="{Binding ImageSource}" Stretch="Uniform"  MaxWidth="40" MaxHeight="40" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2"/>

            <TextBlock FontSize="12" Text="{Binding Title}" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="WrapWholeWords" Grid.Column="1" Grid.Row="0"/>

            <TextBlock FontSize="8" Text="{Binding SubTitle}" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="WrapWholeWords" Grid.Column="1" Grid.Row="1"/>
        </Grid>
    </DataTemplate>

    <Style x:Key="ListViewKnowledgeSystemDiagramStyles" TargetType="ListView">
        <Setter Property="Background" Value="#FFE5E5E5"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="ListViewItem">
                    <Setter Property="Background" Value="White"/>
                    <Setter Property="Margin" Value="5,5,5,0"/>
                    <Setter Property="Padding" Value="0"/>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemTemplateSelector">
            <Setter.Value>
                <templateSelector:KnowledgeSystemDiagramDataTemplateSelector DataTemplateSelectionWhenTrue="{StaticResource GridViewKnowledgeSystemDiagramDataTemplateForPhone}" DataTemplateSelectionWhenFalse="{StaticResource GridViewKnowledgeSystemDiagramDataTemplateForPC}"/>
            </Setter.Value>
        </Setter>
    </Style>
View Code

设置宽度之前

 

设置宽度之后

Sago的主页 Sago | 初学一级 | 园豆:48
提问于:2015-08-02 17:58
< >
分享
所有回答(1)
0

我也遇到一样的问题,我是在PC上的UWP第一行会消失,但是图片还在,用vs2015实时可视化树打开去看,没找到原因,看起来并不是visibility的问题,在可视化树上点击地二行的时候,第二行的也消失了。头疼,求大神。

醉梦ai天涯 | 园豆:202 (菜鸟二级) | 2016-11-24 09:48
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册