-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
BitmapIcon markup extension #3130
BitmapIcon markup extension #3130
Conversation
Co-Authored-By: Michael Hawker MSFT (XAML Llama) <[email protected]>
Co-Authored-By: Michael Hawker MSFT (XAML Llama) <[email protected]>
Co-Authored-By: Michael Hawker MSFT (XAML Llama) <[email protected]>
…io0694/WindowsCommunityToolkit into feature/font-icon-extension
Thanks Sergio0694 for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌 |
public bool ShowAsMonochrome { get; set; } | ||
|
||
/// <inheritdoc/> | ||
protected override object ProvideValue() |
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.
protected override object ProvideValue() [](start = 8, length = 40)
It can be a body-less method:
protected override object ProvideValue() => new BitmapIcon
{
ShowAsMonochrome = ShowAsMonochrome,
UriSource = Source
};
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.
Not really a fan of how the body expression looks in small methods returning an object like this, as at a glance it's easy to confuse the brackets under the method with the actual brackets for the method body, when in fact they belong to that constructor instead.
I'd prefer to leave this as is if that's alright, but let me know what you think! 😊
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.
@vgromfeld do you have any pros/cons around the styling of this one way or the other, I know this is a newer feature of C# compared to when the Toolkit started, so I don't think we have any explicit styling guidelines setup for this scenario. Honestly though, I'm fine with either.
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.
The body-less generally allows us to remove all the unneeded characters and write more compact code. It might be less natural first but really helps to read the code faster once you get use to it 😀.
VS2019 code style is recommending this approach. It definitively don't worth a full restyling of all the toolkit code but should be more and more considered when writing new code.
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.
@Sergio0694 can we just merge this into the PR for #3110 since it provide very similar functionality? Thanks! |
…sion FontIconSource extension
This PR is part of the group being tracked in #3108.
PR Type
What kind of change does this PR introduce?
What is the new behavior?
A XAML markup extension that creates a
BitmapIcon
instance, resulting in much cleaner code (see here). All additional info can be found in the linked issue.This issue is related to #3110.
PR Checklist
Please check if your PR fulfills the following requirements: