-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Made TabControl observe changes which affect SelectedContent/Template, plus various analyzer warning fixes #11366
Made TabControl observe changes which affect SelectedContent/Template, plus various analyzer warning fixes #11366
Conversation
…entTemplate. The next commit will fix both.
…the selected tab changes Flipped ContentTemplate priority to match WPF, where TabItem's template wins over TabControl's Made various properties read-only DirectProperty
Updated desktop solution filter
You can test this PR using the following package version. |
Avalonia/src/Avalonia.Controls/TabItem.cs Line 85 in 91ff652
|
You can test this PR using the following package version. |
Does this mean TabStripPlacement can't be set in a style? And why the limitation to DirectProperty? |
|
Just ran across TabControl not working with a custom ContentTemplate. Hopefully this makes it in for RC otherwise TabControl doesn't work with MVVM and dynamic tab items set with ItemsSource. |
@Gillibald ping. |
While fixing analyzer warnings, I noticed that
TabControl
andTabItems
only synchronise content and content templates when the selected item changes. I switched them to bindings/observables, so that changes are applied immediately, e.g. in response to a style trigger.I also noticed that
TabControl.ContentTemplate
was either not used at all (for a user-providedTabItem
) or always used (for a generatedTabItem
). WPF evaluates both every time, andTabItem.ContentTemplate
wins if not null. This PR introduces the same precedence rules.The PR also contains the set of fixes for / suppressions of analyzer warnings that I originally set out to make, plus an update to
Avalonia.Desktop.slnf
which corrects the paths to some projects.TabControl specifics
TabItem.TabStripPlacement
is now aDirectProperty
. I applied the same pattern that I used inScrollBar
to subscribe toTabControl.TabStripPlacement
and forward the value. The value also is now nullable, so won't incorrectly returnDock.Left
when there isn't aTabControl
around.TabControl.SelectedContent
andTabControl.SelectedContentTemplate
are now direct and read-only. These previously had analyzer suppression attributes saying that they were "supposed to be a styled readonly property", but this doesn't make sense, as they are set with local priority byTabControl
and thus can never be styled.Additionally, both of those properties are now set by observable subscribers. This means that changes to
TabControl.ContentTemplate
,TabItem.ContentTemplate
, andTabItem.Content
are now reflected immediately, instead of when the selected tab next changes.TabControl.UpdateHeader
I didn't change this method despite the warnings it is emitting. It's a weird feature and I don't know what to do with it. Is it really desirable to sometimes automatically set the header when the content changes?
I think we should delete this code, and let users create their own attached behaviour if they actually want the functionality.
Breaking changes
TabControl.ContentTemplate
is now used ifTabItem.ContentTemplate
is null. This matches WPF.