SfAvatarView - Behavior of HeightRequest / WidthRequest with AvatarShape.Custom not documented

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:

  1. Updating the documentation for SfAvatarView and/or AvatarShape to explicitly mention this?

  2. 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 !


1 Reply

KJ Kishore Jeyachandran Syncfusion Team June 4, 2025 10:10 AM UTC

Hi Duo,

 

Thank you for taking the time to investigate and share such a detailed report regarding the behavior of SfAvatarView.

 

You're absolutely right HeightRequest and WidthRequest are only applied when AvatarShape is set to Custom, which is the intended behavior of the AvatarShape property. However, we understand that this may not be immediately obvious and can lead to confusion during implementation.

 

Based on your feedback, we will take the following steps:

 

  1. Documentation Update:
    We will update the official documentation for both SfAvatarView and AvatarShape to clearly explain this behavior.

 

  1. Logging or Tracing (Future Consideration):
    We will also consider adding logging or tracing information in a future release to help developers identify when sizing is overridden due to AvatarShape not being set to Custom.

 

Thank you once again for your valuable input and please feel free to reach out if you need further assistance.

 

Regards,

Kishore J


Loader.
Up arrow icon