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

Eliminated the need to pass the owning BaseMetroTabControl to MetroTabItem #1624

Merged
merged 6 commits into from
Oct 30, 2014

Conversation

thoemmi
Copy link
Collaborator

@thoemmi thoemmi commented Oct 29, 2014

Currently MetroTabItem has a public property OwningTabControl which is required when closing a tab (confer #555 and #631).

I eliminated the need for this property by finding the BaseMetroTabControl at runtime. This makes it much easier to add tabs dynamically in a MVVM application, because you don't need to pass the BaseMetroTabControl to MetroTabItem's constructor.

I kept the old, now superfluous constructor, but added a ObsoleteAttribute, because it is a breaking change. Feel free to remove that c'tor.

@@ -114,14 +111,15 @@ void closeButton_Click(object sender, RoutedEventArgs e)
CloseTabCommandParameter = null;
}

if (OwningTabControl == null) // see #555
var owningTabControl = FindParent<BaseMetroTabControl>(this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thoemmi there is always a TryFindParent function at TreeHelper static class, maybe we can use this one...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed TreeHelper but associated it with the TreeView control like other XxxHelper classes.

I'll fix my code by calling TreeHelper.TryFindParent

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thoemmi :-D i know, maybe TreeHelper is better than other, it has helper funtions for visual and logical tree helper...

@flagbug
Copy link
Member

flagbug commented Oct 29, 2014

@thoemmi You can remove the old constructor, no problem

@thoemmi
Copy link
Collaborator Author

thoemmi commented Oct 29, 2014

Changed to use TreeHelper.TryFindParent.

What do you think about the now obsolete c'tor? The migration guide says that all obsolete stuff has been removed.

@thoemmi
Copy link
Collaborator Author

thoemmi commented Oct 29, 2014

I've removed the obsolete c'tor

@flagbug flagbug added this to the v1.0 milestone Oct 30, 2014
flagbug added a commit that referenced this pull request Oct 30, 2014
…ontrol

Eliminated the need to pass the owning BaseMetroTabControl to MetroTabItem
@flagbug flagbug merged commit 0751903 into MahApps:master Oct 30, 2014
@flagbug
Copy link
Member

flagbug commented Oct 30, 2014

Thanks @thoemmi !

@thoemmi thoemmi deleted the MetroTabItem-without-OwningTabControl branch October 30, 2014 23:18
@thoemmi thoemmi restored the MetroTabItem-without-OwningTabControl branch November 16, 2014 18:26
@thoemmi thoemmi deleted the MetroTabItem-without-OwningTabControl branch November 16, 2014 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants