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

Setting MaterialTabControl.SelectedIndex/Tab in a form's initializer doesn't move the tab indicator #6

Closed
AlexxEG opened this issue Dec 29, 2014 · 2 comments

Comments

@AlexxEG
Copy link
Contributor

AlexxEG commented Dec 29, 2014

Also setting the SelectedIndex/Tab in Form.Load event causes a crash at this line:

var rippleSize = (int)(animationProgress * TabRects[baseTabControl.SelectedIndex].Width * 1.75);

with this exception:

Additional information: Index was out of range. Must be non-negative and less than the size of the collection.

because 'TabRects' is not initialized yet.

Also can I suggest that when setting the SelectedIndex/Tab programmatically that the ripple effect should expand from the middle, if at all.

Great work btw, I love Android's Material Design 👍

IgnaceMaes added a commit that referenced this issue Dec 29, 2014
@IgnaceMaes
Copy link
Owner

Thanks for notifying this problem, I hadn't thought about it.

I fixed the IndexOutOfBoundsException by leaving the TabRects by default on null and updating them in the paint if they're null.

The tab indicator not moving on initialization was cause by having no/the wrong previousSelectedTabIndex. It's now automatically set to the selected tab in when assigning a baseTabControl. If it's -1 it just takes the current selected index.

I'm not sure if a ripple animation should be shown when programmatically changing the SelectedIndex because it represents a user interaction. However if it gets in there, starting from the center would be the most logical. I'll think about it.

And I'm glad you like it so far! There is still a lot of controls to be made ;)

@AlexxEG
Copy link
Contributor Author

AlexxEG commented Dec 29, 2014

No problem :)

I would say no ripple animation when changing programmatically would be best then.

SavanDev pushed a commit to SavanDev/PhoenixForms that referenced this issue Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants