Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlipView SelectedIndex resetting bug #2333

Closed
berkay2578 opened this issue Jan 30, 2016 · 0 comments
Closed

FlipView SelectedIndex resetting bug #2333

berkay2578 opened this issue Jan 30, 2016 · 0 comments
Assignees
Labels
Milestone

Comments

@berkay2578
Copy link

Update:

After a bit of tinkering I found out that whether FlipView.SelectedIndex is attached to a Binding, changing the active Tab will make it go back to Index 0. However, this will only happen once. If you change the Tab and then go back, FlipView will no longer reset back to Index 0 after you change tabs.


I'm experiencing this bug in my own project, which you can access through https://github.com/berkay2578/nfsw-server. You can find the code-behind related to the FlipView in the MainWindow.xaml.cs on the lines 104-131; or:

#region FlipViewPersona
            FlipViewPersonaImage.HideControlButtons();

            Grid[] aFlipViewAvatarArray = new Grid[28];
            for (int i = 0; i < 28; i++)
            {
                Grid Grid_FlipViewDummy;
                Image Image_FlipViewDummy;
                Image_FlipViewDummy = new Image() { Margin = new Thickness(7d), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Stretch = Stretch.Uniform, Source = (ImageSource)BitmapFrame.Create(new Uri("pack://application:,,,/OfflineServer;component/images/NFSW_Avatars/Avatar_" + i.ToString() + ".png", UriKind.Absolute)) };
                Grid_FlipViewDummy = new Grid() { Margin = new Thickness(-8d) };
                Grid_FlipViewDummy.Children.Add(Image_FlipViewDummy);
                Image t1 = new Image() { Source = Image_FlipViewDummy.Source };
                t1.Effect = new System.Windows.Media.Effects.BlurEffect() { Radius = 7.5d };
                Grid_FlipViewDummy.Background = new VisualBrush((Visual)t1);
                aFlipViewAvatarArray[i] = Grid_FlipViewDummy;
            }
            FlipViewPersonaImage.ItemsSource = aFlipViewAvatarArray;

            Binding indexBind = new Binding()
            {
                Path = new PropertyPath("mPersona.shAvatarIndex"),
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Mode = BindingMode.TwoWay,
                Source = mCurrentSession
            };
            FlipViewPersonaImage.SelectedIndex = mCurrentSession.mPersona.shAvatarIndex;
            BindingOperations.SetBinding(FlipViewPersonaImage, FlipView.SelectedIndexProperty, indexBind);
            #endregion

If you have any questions, please ask and I will respond shortly thereafter.

Versions: 1.1.2-STABLE, 1.2.4-STABLE, 1.3.0-ALPHA028.
Environment: VS2015 Enterprise, .Net Framework 4.0
Steps:

  1. Create a TabControl with 2 or more TabItems.
  2. Put Grids in them.(It should do it by default but just to make sure)
  3. Put a FlipView into the first Tab's Grid.
  4. Attach items to it through code-behind.
  5. Launch application, change the active item of FlipView.
  6. Change the active tab and go back.
  7. FlipView will have Index set to 0.

  1. In the current form of my project, just launch it. It will set Index to 0 even though application returns 27(mCurrentSession->mPersona->shAvatarIndex).

  1. Add the binding to the FlipView_Loaded event.
  2. When launched, it will have Index set to 27 correctly.
  3. Change the tab, then change it back to "Persona". FlipView will have it's Index set to 0.

Operating System: Windows 10 x64, Windows 8.1 x64; both up-to-date
Outcome: Resetting problem fixed for the FlipView, as it almost always returns back Index: 0.

@berkay2578 berkay2578 changed the title FlipView SelectedIndex Binding bug FlipView SelectedIndex resetting bug Jan 30, 2016
petvetbr added a commit to petvetbr/MahApps.Metro that referenced this issue Mar 2, 2016
@punker76 punker76 added this to the 1.3.0 milestone Mar 16, 2016
@punker76 punker76 self-assigned this Mar 16, 2016
punker76 added a commit that referenced this issue Mar 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants