Xaml/win8で新しく作成された空白のページで問題が発生しています。これが私のコードです:
<common:LayoutAwarePage
x:Name="pageRoot"
x:Class="MyApp.Contents"
DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyApp"
xmlns:common="using:MyApp.Common"
xmlns:data="using:MyApp.Data"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<!-- Collection of items displayed by this page -->
<CollectionViewSource
x:Name="itemsViewSource"
Source="{Binding Items}"
d:Source="{Binding TestSource.Items, Source={d:DesignInstance Type=data:MyDataSource, IsDesignTimeCreatable=True}}"/>
</Page.Resources>
<!-- Snip Grid and Back Button -->
<ListView
x:Name="itemListView"
AutomationProperties.AutomationId="ItemsListView"
AutomationProperties.Name="Items"
TabIndex="1"
Grid.Row="1"
Margin="-10,-10,0,0"
Padding="120,0,0,60"
ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
IsSwipeEnabled="False"
ItemTemplate="{StaticResource ItemTemplate}"/>
そして、これをサポートするC#(TestSourceコンストラクター)は次のとおりです。
for (int i = 0; i < 20; ++i)
TestSource.Items.Add(new ExampleData(TestSource));
デザイナでは、これは適切に機能します。期待どおりに20個のExampleDataのリストが表示されます。
しかし、アプリを実行すると、ページに何も表示されません。「ExampleData」アイテムは表示されません(「TestSource.Items」監視可能コレクションが適切に入力されたと確信していますが)。
私は主に、SplitViewデモからこのバインディングの例をコピーして貼り付けました。誰かが何が悪いのかわかりますか?= [