Articles in this section
Category / Section

How to bind StaticResource to ImageSource in .NET MAUI AvatarView (SfAvatarView)?

2 mins read

In the .NET MAUI Avatar View control, the ImageSource property is used to display an image within the avatar. In this scenario, the image is connected to the ImageSource property via a StaticResource.

This procedure involves establishing a key-value pairing within a resource collection where the key signifies the image’s name. The key name is subsequently referenced using the StaticResource markup extension.

XAML

<ContentPage.Resources>
      <x:String x:Key="avatarImage">avatar.png</x:String>
 </ContentPage.Resources>
<Grid>
    <sfavatar:SfAvatarView ContentType="Custom" 
                           ImageSource="{StaticResource avatarImage}"
                           VerticalOptions="Center"
                           HorizontalOptions="Center"   
                           HeightRequest="50"
                           CornerRadius="25"
                           WidthRequest="50"/>
</Grid>

Output

avatarImage.jpg

Conclusion

I hope you enjoyed learning how to bind StaticResource to ImageSource in .NET MAUI Avatar View (SfAvatarView).

You can refer to our .NET MAUI Avatar View’s feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI Avatar View documentation to understand how to present and manipulate data.

For current customers, you can check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our .NET MAUI Avatar View and other .NET MAUI components.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied