Skip to content

[SettingsControls] Switch to object type for ItemTemplate property#417

Merged
niels9001 merged 5 commits intoCommunityToolkit:mainfrom
yourordinarycat:feature/expander-template-selection
Apr 12, 2023
Merged

[SettingsControls] Switch to object type for ItemTemplate property#417
niels9001 merged 5 commits intoCommunityToolkit:mainfrom
yourordinarycat:feature/expander-template-selection

Conversation

@yourordinarycat
Copy link
Copy Markdown
Contributor

@yourordinarycat yourordinarycat commented Apr 11, 2023

The ItemsRepeater.ItemTemplate property allows using a DataTemplate, DataTemplateSelector or IElementFactory. This is quite convenient to have, and to allow for this, the property is of type IInspectable (and from C# we see object :D)

SettingsExpander has an ItemTemplate property as well, but it only allows setting a DataTemplate, and because of the lack of extra properties in the ItemsRepeater, it's not possible to use a template selector or element factory. This PR addresses the problem by switching to object for the ItemTemplate property.

@yourordinarycat
Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

Comment thread components/SettingsControls/src/SettingsExpander/SettingsExpander.xaml Outdated
@yourordinarycat yourordinarycat marked this pull request as ready for review April 12, 2023 04:04
@yourordinarycat
Copy link
Copy Markdown
Contributor Author

yourordinarycat commented Apr 12, 2023

New sample

Got a new sample in - should be good now 👍

Copy link
Copy Markdown
Contributor

@niels9001 niels9001 left a comment

Choose a reason for hiding this comment

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

Tested.. works great. Great job @yourordinarycat :)!

This can be merged once the XAML styler issue is resolved:

D:\a\Labs-Windows\Labs-Windows\ApplyXamlStyling.ps1 : XAML Styling is incorrect, please run locally:
ApplyXamlStyling.ps1 -Main

If you run ApplyXamlStyling.ps1 -Main and push the changes CI should pass :)

@yourordinarycat
Copy link
Copy Markdown
Contributor Author

Should pass now - as an aside, is there something I'm missing from my setup? The script was failing initially:

Script failing

I could fix it by replacing line 100:

dotnet tool run xstyler -p -c .\settings.xamlstyler -f $files

With:

xstyler -p -c .\settings.xamlstyler -f $files

Not sure if it's just a me thing, but it did work, so it should be good for now~

@Arlodotexe
Copy link
Copy Markdown
Member

Arlodotexe commented Apr 12, 2023

@yourordinarycat Running dotnet tool restore once should fix the issue. We do this for you automatically in the PowerShell script, I'm not sure why it didn't work for you 🤔

@niels9001 niels9001 merged commit bfc2c90 into CommunityToolkit:main Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants