I am building a UWP Windows 10 App. In a Page I have a FlipView that has static items. Instead of binding them to an ItemsSource, it was easier to set them in Xaml as:
<FlipView x:Name="myFlipView">
<FlipViewItem>...</FlipViewItem>
<FlipViewItem>...</FlipViewItem>
</FlipView>
I want to add an Indicators Control to this FlipView as in this tutorial: http://blog.jerrynixon.com/2014/04/lets-code-build-your-own-flipview-page.html
When I want to set the ItemsSource of my <ItemsControl x:Name="Indicators">
I want to set it to the FlipView's ItemsSource.
I tried setting it in code as Indicators.ItemsSource = myFlipView.ItemsSource;
but it is empty as it is set statically in Xaml. Any idea how to do that?
Edit:
I have used a GridView instead of an ItemsControl since ItemsControl doesn't have a SelectedIndex property like mentioned here: flipView and Page indicator UWP
I set it like that:
<GridView x:Name="Indicators" ItemsSource="{Binding ItemsSource, ElementName=myFlipView}" SelectedIndex="{Binding SelectedIndex, ElementName=myFlipView}">...</GridView>
But it is crashing and throws an Unhandled Exception that I can't catch.
来源:https://stackoverflow.com/questions/37423498/set-itemssource-of-control-to-another-controls-itemssource-that-is-static-and-s