0

对于Windows 8.1xaml中的listview似乎是一个奇怪的问题,我遇到了麻烦。我在 Windows 8.1 上使用VS 2013 Preview附带的 Hub 示例模板。无论出于何种原因,列表视图中的第一个条目都不会出现。我将列表视图与应用程序中提供的示例 JSON 数据绑定。无论是绑定到示例数据还是绑定到 sqlite db 文件中的我自己的数据,都没有区别。我会发布一张图片,但我在 stackoverflow 上还没有足够的声誉......目的是用列表示表中的数据。xaml 中的所有内容都有效,只是它隐藏了列表视图中的第一个条目......

这是代码。

<Grid x:Name="TransactionGrid" Grid.Column="1" Grid.Row="1"
            Background="{ThemeResource AppBarItemBackgroundThemeBrush}"
            DataContext="{Binding Group}"
            d:DataContext="{Binding Groups[0], Source={d:DesignData Source=/DataModel/SampleData.json, Type=data:SampleDataSource}}">

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <Grid x:Name="TransactionHeader" Margin="0,0,0,5"> 
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width=".5*"/>
                <ColumnDefinition Width="1.5*"/>
                <ColumnDefinition Width="1.25*"/>
                <ColumnDefinition Width="1.75*"/>
                <ColumnDefinition Width=".75*"/>
                <ColumnDefinition Width=".75*"/>
                <ColumnDefinition Width=".25*"/>
            </Grid.ColumnDefinitions>

            <TextBlock Grid.Column="0" 
                 Text="Date" 
                 Style="{StaticResource SubheaderTextBlockStyle}"
                 HorizontalAlignment="Center" Margin="0,0,0,5"/>

            <TextBlock Grid.Column="1" 
                 Text="Payee" 
                 Style="{StaticResource SubheaderTextBlockStyle}"
                 HorizontalAlignment="Left" Margin="0,0,0,5"/>

            <TextBlock Grid.Column="2" 
                 Text="Category" 
                 Style="{StaticResource SubheaderTextBlockStyle}" 
                 HorizontalAlignment="Left" Margin="0,0,0,5"/>

            <TextBlock Grid.Column="3" 
                 Text="Description" 
                 Style="{StaticResource SubheaderTextBlockStyle}" 
                 HorizontalAlignment="Left" Margin="0,0,0,5"/>

            <TextBlock Grid.Column="4" 
                 Text="Amount" 
                 Style="{StaticResource SubheaderTextBlockStyle}" 
                 HorizontalAlignment="Right" Margin="0,0,0,5"/>

            <TextBlock Grid.Column="5" 
                 Text="Balance" 
                 Style="{StaticResource SubheaderTextBlockStyle}" 
                 HorizontalAlignment="Right" Margin="0,0,0,5"/>
        </Grid>

        <ListView x:Name="TransactionListview"  
                Grid.Row="1"
                ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
                IsSynchronizedWithCurrentItem="False" IsItemClickEnabled="True">

            <ListView.ItemTemplate>                    
                <DataTemplate>
                    <Grid Width="{Binding ElementName=TransactionListview, Path=ActualWidth}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width=".5*"/>
                            <ColumnDefinition Width="1.5*"/>
                            <ColumnDefinition Width="1.25*"/>
                            <ColumnDefinition Width="1.75*"/>
                            <ColumnDefinition Width=".75*"/>
                            <ColumnDefinition Width=".75*"/>
                            <ColumnDefinition Width=".25*"/>
                        </Grid.ColumnDefinitions>

                        <Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}" 
                            Width="Auto" 
                            Height="40" 
                            Grid.ColumnSpan="7" />

                        <TextBlock Grid.Column="0" 
                            Text="{Binding Title}" 
                            HorizontalAlignment="Left" 
                            VerticalAlignment="Center" 
                            Margin = "1,0,0,0"
                            FontSize="17" />

                        <TextBlock Grid.Column="1" 
                            Text="{Binding Subtitle}" 
                            HorizontalAlignment="Left" 
                            VerticalAlignment="Center"
                            FontSize="17"/>

                        <TextBlock Grid.Column="2" 
                            Text="{Binding ImagePath}" 
                            HorizontalAlignment="Left" 
                            VerticalAlignment="Center"
                            FontSize="17"/>

                        <TextBlock Grid.Column="3" 
                            Text="{Binding Description}" 
                            HorizontalAlignment="Left" 
                            VerticalAlignment="Center" 
                            Margin = "0,0,20,0"
                            FontSize="17"/>

                        <TextBlock Grid.Column="4" 
                            Text="{Binding Title}" 
                            HorizontalAlignment="Right" 
                            VerticalAlignment="Center"
                            FontSize="17"/>

                        <TextBlock Grid.Column="5" 
                            Text="{Binding Title}" 
                            HorizontalAlignment="Right" 
                            VerticalAlignment="Center"
                            FontSize="17"/>
                    </Grid>
                </DataTemplate>                
            </ListView.ItemTemplate>
        </ListView>
    </Grid>
4

1 回答 1

1

这是交叉发布到产品团队正在回答的 MSDN 论坛:http: //social.msdn.microsoft.com/Forums/windowsapps/en-US/8b9f3365-97d5-4405-a677-7b8638a32312/xaml-listview-in- win-81-not-showing-first-entry

于 2013-08-06T18:37:01.817 回答