Answered by:
Auto scroll the Flipview inside of HubSection in windows store app

Question
-
I am trying to auto flip the item of FlipView Items in windows store app. I have tried the following code.
public MainPage() { InitializeComponent(); //Configure the timer _timer = new DispatcherTimer { //Set the interval between ticks (in this case 2 seconds to see it working) Interval = TimeSpan.FromSeconds(2) }; //Change what's displayed when the timer ticks _timer.Tick += ChangeImage; //Start the timer _timer.Start(); } /// <summary> /// Changes the image when the timer ticks /// </summary> /// <param name="sender"></param> /// <param name="o"></param> private void ChangeImage(object sender, object o) { //Get the number of items in the flip view var totalItems = TheFlipView.Items.Count; //Figure out the new item's index (the current index plus one, if the next item would be out of range, go back to zero) var newItemIndex = (TheFlipView.SelectedIndex + 1) % totalItems; //Set the displayed item's index on the flip view TheFlipView.SelectedIndex = newItemIndex; }
But i am not able to access the FlipView from .cs file because of the FlipView defined inside of HubSection. How can i solve this? Is there any way of accessing the FlipView or any other way of auto flip the item of FlipView.
Sumit Tuladhar
Wednesday, July 30, 2014 10:28 AM
Answers
-
Hi,
You can not access the control in hubsection. Because you cannot access elements via x:Name in the codebehind-file if they are part of a DataTemplate.
You can create a EventHandler for the FlipView and store the FlipView in a field of your page:
<FlipView x:Name="myFlipView" Loaded="myFlipView_Loaded">
FlipView myFlipView; private void myFlipView_Loaded(object sender, RoutedEventArgs e) { myFlipView= (FlipView)sender; }
And also there are similar issue you can refer to:
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.
- Marked as answer by Anne Jing Thursday, August 7, 2014 1:16 AM
Thursday, July 31, 2014 2:05 AM
All replies
-
Wednesday, July 30, 2014 12:01 PM
-
Hi,
You can not access the control in hubsection. Because you cannot access elements via x:Name in the codebehind-file if they are part of a DataTemplate.
You can create a EventHandler for the FlipView and store the FlipView in a field of your page:
<FlipView x:Name="myFlipView" Loaded="myFlipView_Loaded">
FlipView myFlipView; private void myFlipView_Loaded(object sender, RoutedEventArgs e) { myFlipView= (FlipView)sender; }
And also there are similar issue you can refer to:
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.
- Marked as answer by Anne Jing Thursday, August 7, 2014 1:16 AM
Thursday, July 31, 2014 2:05 AM