0

以下のように定義されたテンプレートを持つ Windows 8.1 アプリ (RT) に FlipView があります。

<FlipView Grid.Row="3"
          Grid.ColumnSpan="2" x:Name="FlipView1" BorderBrush="Black"
          ItemsSource="{Binding ItemsCollection, RelativeSource={RelativeSource TemplatedParent}}">
            <FlipView.ItemTemplate>
                    <DataTemplate>
                          <ScrollViewer>
                                <Grid>
                                    <local:UserControlA x:Name="PART_UserControlA"/>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="100" />
                                            <ColumnDefinition />
                                        </Grid.ColumnDefinitions>
                                        <local:UserControlB Grid.Column="1"
                                                            View="{Binding View}"
                                                            x:Name="PART_UserControlB"
                                                            ItemsSource="{Binding ItemsSourcePropertyOfAnItemInItemsCollection}"
                                                            ItemTemplate="{Binding TemplatePropertyOfAnItemInItemsCollection}" />
                                    </Grid>
                                </Grid>
                          </ScrollViewer>

                    </DataTemplate>
            </FlipView.ItemTemplate>
</FlipView>

基本的に、このフリップ ビューは、カレンダー コントロールを表示するために使用されています。したがって、選択変更イベントで項目を追加することになっています (次/前の月/週のカレンダーを表示するため)。コードビハインドでそれを行うにはどうすればよいですか? には sayのItemsCollectionコレクションが含まれていますObjectA。新しいオブジェクトの準備ができました (これは、フリップビューの ItemsSource コレクションに追加されます。また、それをフリップ ビューの ItemsSource にも追加しています。しかし、単に新しいアイテムを追加するだけではありません。アイテムソース?

4

1 に答える 1

0

ああ、私の WPF 知識不足は無視してください。ItemsCollection を ObservableCollection にし、バインディングを TwoWay として定義するのと同じくらい簡単でした。ItemsSource="{Binding ItemsCollection, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"

于 2016-01-07T02:02:53.440 に答える