Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix badge transparent border color issue and add margin property (#2783)
Description
Fixes an issue where badge borders with transparent color incorrectly render as visible colored borders during pulse animation, and adds a configurable
BadgeMarginproperty for badge positioning.Problem
Transparent Border Color Issue: When using pulse animation on a badge with
RoundedRectangleshape andbadgeBorderColor: Transparent(with no bevel effect), the transparent border was incorrectly being rendered as a semi-transparent version of the badge color during animation. The opacity calculation was applying to transparent colors, creating an incorrect visible color instead of remaining transparent.Missing Margin/Padding Control: The badge offset from the button edge was hardcoded as a constant (3 pixels), preventing customization of badge positioning per instance.
Solution
1. Transparent Border Color Fix
DrawBadgeBordermethod to skip drawing when border color alpha is 0Color.FromArgb((int)(opacity * borderColor.A), ...)instead of hardcoded 255DrawBevelBordermethod for safety2. Margin Property Addition
BadgeMarginproperty toBadgeContentValuesclass with default value of 5 pixelsViewDrawBadge.CalculateBadgeLocationto use_badgeValues.BadgeContentValues.BadgeMargininstead of hardcodedBADGE_OFFSETconstantBADGE_OFFSETconstantChanges Made
Core Fixes
ViewDrawBadge.cs:DrawBadgeBordermethod to check for transparent colors (A=0) and skip drawingDrawBevelBordermethod with transparency checkCalculateBadgeLocationto use configurable margin propertyBADGE_OFFSETconstantNew Feature
BadgeContentValues.cs:DEFAULT_BADGE_MARGINconstant (5 pixels)_badgeMargininstance fieldBadgeMarginproperty with validation (minimum 0)IsDefaultcheck to include badge marginShouldSerializeBadgeMarginandResetBadgeMarginmethodsUsage
Setting Custom Margin
Testing
The fix has been tested with:
Behavior
Breaking Changes
None. This is a bug fix and feature addition that maintains backward compatibility: