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>

基本上,此翻转视图用于显示日历控件。所以,我应该在选择更改事件上添加项目(以显示下一个/前几个月/几周的日历)。我怎样才能在后面的代码中做到这一点?ItemsCollection包含 say 的集合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 回答