Xamarin.CommunityToolkit by Microsoft

<PackageReference Include="Xamarin.CommunityToolkit" Version="2.0.6" />

 FileMediaSourceConverter

public sealed class FileMediaSourceConverter : TypeConverter
using System; using System.Runtime.CompilerServices; using Xamarin.Forms.Xaml; namespace Xamarin.CommunityToolkit.Core { [TypeConversion(typeof(FileMediaSource))] public sealed class FileMediaSourceConverter { [System.Runtime.CompilerServices.NullableContext(1)] public override object ConvertFromInvariantString(string value) { if (value == null) throw new InvalidOperationException($"""{value}""{typeof(FileMediaSource)}"); return (FileMediaSource)MediaSource.FromFile(value); } public FileMediaSourceConverter() : this() { } } }