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

Fix issue with TabPaneFooter Width/MinWidth not being respected #3531

Merged

Conversation

marcelwgn
Copy link
Contributor

@marcelwgn marcelwgn commented Oct 30, 2020

Description

The layout of the TabView didn't take into account changes of the Width/MinWidth property of the TabPaneFooter. This PR changes that and listens to changes made to those two properties.

Motivation and Context

Closes #1615 , not sure if would close issue #3280

How Has This Been Tested?

Add new API test, also checked in the tear out sample of the XCG for future testing of that scenario (e.g. new titlebar api for TabView)

Screenshots (if appropriate):

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Oct 30, 2020
@StephenLPeters StephenLPeters added area-TabView team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Oct 30, 2020
@ranjeshj ranjeshj requested a review from teaP November 21, 2020 13:44
}
if (const auto newFooter = args.NewValue().try_as<winrt::FrameworkElement>())
{
m_footerMinWidthProperyChangedToken = newFooter.RegisterPropertyChangedCallback(winrt::FrameworkElement::MinWidthProperty(), { this,&TabView::OnComponentSizeChanged });
Copy link
Contributor

Choose a reason for hiding this comment

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

can these be done using a revoker ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that's possible. We need to listen to more or less generic dependency property changes, there is no dedicated (Min)WidthPropertyChanged event, so we need to use that route. Unfortunately, RegisterPropertyChangedCallback only works through tokens.

Copy link
Contributor

Choose a reason for hiding this comment

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

@chingucoding please use the cpp winrt helper RegisterPropertyChanged

inline PropertyChanged_revoker RegisterPropertyChanged(winrt::DependencyObject const& object, winrt::DependencyProperty const& dp, winrt::DependencyPropertyChangedCallback const& callback)


In reply to: 528202327 [](ancestors = 528202327)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, wish I knew that existed earlier. Is fixed now.

I also noticed that a lot of the code uses the token pattern to do this, should we updated all occurrences to the helper instead of a token?

}
if (const auto newFooter = args.NewValue().try_as<winrt::FrameworkElement>())
{
m_footerMinWidthProperyChangedToken = newFooter.RegisterPropertyChangedCallback(winrt::FrameworkElement::MinWidthProperty(), { this,&TabView::OnComponentSizeChanged });
Copy link
Contributor

Choose a reason for hiding this comment

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

OnComponentSizeChanged [](start = 150, length = 22)

nit: Component sounds very generic. perhaps OnFooterSizeChanged ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, changed the name to OnFooterSizeChanged.

UnhookEventsAndClearFields();
if (const auto footer = TabStripFooter().try_as<winrt::FrameworkElement>())
{
footer.UnregisterPropertyChangedCallback(winrt::FrameworkElement::MinWidthProperty(), m_footerMinWidthProperyChangedToken);
Copy link
Contributor

Choose a reason for hiding this comment

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

m_footerMinWidthProperyChangedToken [](start = 94, length = 35)

Do we need to check to see if this token is not 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it can be 0 if we actually get in there since that would require us to have a footer, yet not having registered to said footer. Anytime the footer changes, we update the tokens so we would need to get here with footer changes being unnoticed by the TabView.

@karkarl karkarl force-pushed the user/chingucoding/tabview-footersizing-behavior branch from 3b346e3 to 7e73dc5 Compare August 22, 2023 23:52
@karkarl
Copy link
Contributor

karkarl commented Aug 22, 2023

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ojhad ojhad merged commit 73990b0 into microsoft:main Aug 23, 2023
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-TabView team-Controls Issue for the Controls team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TabView: Change TabStripFooter's MinWidth when app started with a narrow window is not take effect
5 participants