Hi Syncfusion team ,
I've recently encountered an issue with SfAvatarView that caused some confusion and thought it would be helpful to report it so the documentation can be improved.
Context :
I was attempting to use SfAvatarView inside a custom control and dynamically assign its size via:
AvatarView.HeightRequest = this.Height;
AvatarView.WidthRequest = this.Width;
However, despite setting this.Height and this.Width to 125, the control always rendered at 72. I also ensured:
-
MaximumHeightRequest and MaximumWidthRequest were set to double.PositiveInfinity
-
this.Height and this.Width were correctly set
-
I tested both XAML binding and C# property-setting
-
Yet, the size was still capped
This was confusing because the value 72 corresponds exactly to AvatarSize.ExtraLarge, suggesting the sizing logic was being overridden.
Investigation
After digging into the Syncfusion.Maui.Core source code, I found the cause in SfAvatarView.cs, line ~1958:
private void ApplyAvatarStyleSetting()
{
if (this.AvatarShape == AvatarShape.Custom)
this.SetAvatarSizing(this.WidthRequest, this.HeightRequest, this.CornerRadius, this.FontSize);
else
this.ApplyConstantAvatarStyleSetting();
}
So, it turns out that:
HeightRequest and WidthRequest are only honored if AvatarShape == AvatarShape.Custom.
This is not currently mentioned in the documentation for SfAvatarView or AvatarShape.
Suggestion
Could you please consider:
-
Updating the documentation for SfAvatarView and/or AvatarShape to explicitly mention this?
-
Possibly logging a warning or tracing info if sizing is overridden because AvatarShape != Custom
This would help avoid confusion for other developers trying to dynamically size the avatar view.
Thanks a lot for the great controls and for taking this feedback into account !