-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add default template to the ContentControl, remove theme specific templates #11365
Conversation
I like this change. We are re-theming everything in our application and #4614 was a roadblock that we hit very early on. We can't even identify all the special templates that we need, and over time new ones could easily be introduced. The solution we ended up with was including the simple theme before our own theme, so that we can be certain that we have a template for every obscure low-level control. It would be great if we could avoid doing this. |
@tomenscape popuproot should minimally work, as it's content control as well. Saying that, tests didn't like this change at all. |
I've been thinking about this, here are my thoughts so far: Cons
I'm not sure that's the conclusion I come to when reading that thread: that issue seems more to be asking for any indication of why a control isn't displaying due to a missing template. At the beginning of the project for example, I considered draing a red cross for controls without a template (never did implement this, probably for the best ;) ).
Yeah, the question would be: how far do we go? Because the logical conclusion of this is that we always ship something like the default theme as default templates. Pros
ConclusionI'm still not completely decided on this mainly because of the question "How far do we take this?". But, given that |
Our control unit tests are full of control template factories that create bare minimum templates that only contain parts that are mandatory for the control being used. So having such factory as part of the actual control would help to speed up testing and makes it easier to tests controls that rely on specific parts in their control template. TextBox for example will need a ScrollViewer and a TextPresenter but the ScrollViewer itself isn't functional without a template. So I end up writing a template factory for ScrollViewer and for TextBox just to be able to test. All this requires internal knowledge of the controls being used. |
e408721
to
40aaf82
Compare
Merge queue setting changed
1089591
to
cf3ca88
Compare
@@ -430,7 +430,8 @@ public void FlowDirection_Of_RectangleContent_Updated_After_OpenPopup() | |||
{ | |||
new ComboBoxItem() | |||
{ | |||
Content = parentContent.Child | |||
Content = parentContent.Child, | |||
Template = null // ugly hack, so we can "attach" same child to the two different trees |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hack replicates old test behavior, when there was no template on the ComboBoxItem. Now there is one always.
You can test this PR using the following package version. |
I had a look at the code and it's looking good to me. What's the final consensus about merging this? |
@MrJul after discussion we agreed on removing ItemsControl template and not adding more than ContentControl template. So, this PR should be mergeable now. |
What does the pull request do?
Created this PR as I wanted to do something different in my free time, but what might improve some existing problems.
CC @grokys as I want to hear your opinion about these changes.
There were couple of different discussions before:
Now, adding a default value to the ContentControl.Template solves quite a lot of that:
With all of this, ControlCatalog (with some unrelated modifications) can run without fluent nor simple theme:

Can it be improved futher?
Technically, we can do the same for ItemsControl (which will cover ListBox as well), so it doesn't need to be restyled by every third-party theme.
ScrollViewer with only ScrollViewerPresenter inside, no bars, also can be done in this way, but it 100% will be reimplemented by every third-party theme, so not that many reasons. Possibly only headless.
Other controls are too complicated for that, and also will be restyled in the end anyway.
Fixed issues
Fixes #4614