Skip to content

Conversation

Arlodotexe
Copy link
Member

@Arlodotexe Arlodotexe commented Jun 17, 2022

This PR adds code to the ProjectTemplate demonstrating:

  • Control templates
  • Implicit and custom styles
  • Dependency properties
  • Getting template parts from OnApplyTemplate
  • A simple theme resource
  • The various bindings you can use inside a control template.
  • Variations for classic {Binding} and the newer {x:Bind}

Additional unit tests will be added as part of #160.

Closes #157

@Arlodotexe Arlodotexe added enhancement Improvement to an existing feature dev loop ➰ For issues that impact the core dev-loop of building experiments templating labels Jun 17, 2022
@michael-hawker
Copy link
Member

CI failing:

"D:\a\Labs-Windows\Labs-Windows\labs\CiTestExp\tests\CiTestExp.UnitTests.WinAppSdk\CiTestExp.UnitTests.WinAppSdk.csproj" (default target) (9:6) ->
(XamlPreCompile target) -> 
  D:\a\Labs-Windows\Labs-Windows\labs\CiTestExp\tests\CiTestExp.Tests\ExampleCiTestExpPage.xaml.cs(13,23): error CS0234: The type or namespace name 'Controls' does not exist in the namespace 'Windows.UI.Xaml' (are you missing an assembly reference?) [D:\a\Labs-Windows\Labs-Windows\labs\CiTestExp\tests\CiTestExp.UnitTests.WinAppSdk\CiTestExp.UnitTests.WinAppSdk.csproj]
  D:\a\Labs-Windows\Labs-Windows\labs\CiTestExp\tests\CiTestExp.Tests\ExampleCiTestExpPage.xaml.cs(16,23): error CS0234: The type or namespace name 'Media' does not exist in the namespace 'Windows.UI.Xaml' (are you missing an assembly reference?) [D:\a\Labs-Windows\Labs-Windows\labs\CiTestExp\tests\CiTestExp.UnitTests.WinAppSdk\CiTestExp.UnitTests.WinAppSdk.csproj]
  D:\a\Labs-Windows\Labs-Windows\labs\CiTestExp\tests\CiTestExp.Tests\ExampleCiTestExpPage.xaml.cs(23,52): error CS0246: The type or namespace name 'Page' could not be found (are you missing a using directive or an assembly reference?) [D:\a\Labs-Windows\Labs-Windows\labs\CiTestExp\tests\CiTestExp.UnitTests.WinAppSdk\CiTestExp.UnitTests.WinAppSdk.csproj]

But agree some of this may be resolved by #154, which hopefully we can get in soon.

@michael-hawker
Copy link
Member

@Arlodotexe plan is to rebase this next right? You going to add the example template binding and have the two different controls, eh?

Maybe we merge it then at that point so Matt can start looking at the template generation option split and we can follow-up with example test cases afterwards?

@Arlodotexe
Copy link
Member Author

Arlodotexe commented Jun 23, 2022

I've uncovered an issue with the source generators. Investigating...

Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

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

@Arlodotexe so with both styles the TemplatedControl.cs backing code is effectively the same, though with the TemplatedControlStyle.xaml/cs backed file it doesn't use the OnApplyTemplate method right?

So effectively, we want to have a switch between:

  • .NET Standard w/ no control in source/sample/tests
  • [default] Templated Control with traditional Style/OnApplyTemplate (TemplateControlSample pages)
  • Templated Control with backed resource dictionary file (BackedTemplateControlSamples)

@mrlacey any comments on this PR about things that would make this work better for the template engine for the above?

@Arlodotexe
Copy link
Member Author

So effectively, we want to have a switch between:

  • .NET Standard w/ no control in source/sample/tests
  • [default] Templated Control with traditional Style/OnApplyTemplate (TemplateControlSample pages)
  • Templated Control with backed resource dictionary file (BackedTemplateControlSamples)

@michael-hawker I would add on that the user should have the option to include both backed and non-backed resource dictionary, rather than having to pick one or the other.

@michael-hawker
Copy link
Member

@michael-hawker I would add on that the user should have the option to include both backed and non-backed resource dictionary, rather than having to pick one or the other.

As separate controls? Why would you have them both for a single control? It's odd we'd have independent styles for one control?

@Arlodotexe
Copy link
Member Author

Arlodotexe commented Jun 24, 2022

As separate controls? Why would you have them both for a single control?

Not as separate controls, just as different styles.

It's odd we'd have independent styles for one control?

They would pick/copy whichever one is needed for their scenario, for each control they need to make.

It actually feels odd that we would exclude one or the other entirely. It's entirely plausible that someone might want/need to swap between x:Bind and TemplateBinding for different parts of their library control.

Only including one out of the box means they'd need to copy from the project template just to get the other.

Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

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

Few small name changes to help ensure everything is independent across experiments.

Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

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

Cool, one thing I just thought of is having more details in the markdown to explain the different methodologies of the control templates, but that's just a wiki thing too. Looks good! Just need to wait on CI, but think that'll be good too. Thanks!

@Arlodotexe Arlodotexe merged commit eb2b7d7 into main Jun 28, 2022
@delete-merged-branch delete-merged-branch bot deleted the feature/default-project-controls branch June 28, 2022 23:49
Martin1994 pushed a commit to Martin1994/Labs-Windows that referenced this pull request Sep 2, 2023
…/default-project-controls

Added improved default control and style examples to ProjectTemplate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev loop ➰ For issues that impact the core dev-loop of building experiments enhancement Improvement to an existing feature templating
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide minimal templated control setup as part of template
3 participants