Skip to content

Update BoxPanel custom panel example #3938

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

Merged
merged 1 commit into from
Jul 13, 2022

Conversation

michael-hawker
Copy link
Contributor

Used this as an example for a template we're building in the Windows Community Toolkit and ran into some issues with the sample and code. Figured I'd contribute back to the article here the fixes I had to do.

Fixes:

  • Off-by-one logic error for cutting size of box (for instance try '6' as a value, should be 2x3 not 3x3 still) (from my understanding of the scenario)
  • Missing { in LimitUnboundedSize method
  • Missing ; in ArrangeOverride method
  • Improper definition of a Dependency Property (guidelines are strict here about property and DP names aligning otherwise issues can occur, picked a more standard XAML based Panel name here as well for this scenario.
    • Also added changed callback to invalidate layout so that the dependency property change actually updates the layout of the control immediately.
  • Provided more context for where the adjustment to the code goes.

Used this as an example for a template we're building in the Windows Community Toolkit and ran into some issues with the sample and code. Figured I'd contribute back to the article here the fixes I had to do.

Fixes:
- Off-by-one logic error for cutting size of box (for instance try '6' as a value, should be 2x3 not 3x3 still) (from my understanding of the scenario)
- Missing `{` in `LimitUnboundedSize` method
- Missing `;` in `ArrangeOverride` method
- Improper definition of a Dependency Property (guidelines are strict here about property and DP names aligning otherwise issues can occur, picked a more standard XAML based Panel name here as well for this scenario.
  - Also added changed callback to invalidate layout so that the dependency property change actually updates the layout of the control immediately.
- Provided more context for where the adjustment to the code goes.
@PRMerger8
Copy link
Contributor

@michael-hawker : Thanks for your contribution! The author(s) have been notified to review your proposed change.

@Jak-MS
Copy link
Contributor

Jak-MS commented Jul 13, 2022

@jwmsft

Can you review this PR?

IMPORTANT: When this content is ready to merge, you must add #sign-off in a comment or the approval may get overlooked.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

@PRMerger13 PRMerger13 added the aq-pr-triaged tracking label for the PR review team label Jul 13, 2022
@jwmsft
Copy link
Contributor

jwmsft commented Jul 13, 2022

@michael-hawker, thank you!

@sign-off

@michael-hawker
Copy link
Contributor Author

Thanks folks! Realized after there are some other optimizations around not using so many local variables in the example, but can do that as a separate thing later, if desired.

I know it's also probably to reduce the complexity of the code a bit, but at the same time I feel like it's good to promote best practices. Let me know if you'd like me to open another PR for that after.

@Jak-MS Jak-MS merged commit 254824a into MicrosoftDocs:docs Jul 13, 2022
@jwmsft
Copy link
Contributor

jwmsft commented Jul 14, 2022

Thanks folks! Realized after there are some other optimizations around not using so many local variables in the example, but can do that as a separate thing later, if desired.

I know it's also probably to reduce the complexity of the code a bit, but at the same time I feel like it's good to promote best practices. Let me know if you'd like me to open another PR for that after.

@michael-hawker, thanks for this. It's always a balance between keeping code simple for the docs and showing best practices. For a complete, complex example like this, I think it's okay to make it more complex and show the best practices. Please feel free to open another PR with your optimizations.

learn-build-service-prod bot pushed a commit that referenced this pull request Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants