Repository: microsoft/PowerToys
File: src/modules/peek/Peek.FilePreviewer/FilePreview.xaml.cs (C#)

Code before:
        private async Task UpdateImageTooltipAsync()
        {
            if (File == null)
            {
                return;
            }

            imageTooltip = string.Empty;

            // Fetch and format available file properties
            imageTooltip += ReadableStringHelper.FormatResourceString("PreviewTooltip_FileName", File.FileName);

            string fileType = await PropertyHelper.GetFileType(File.Path);
            imageTooltip += string.IsNullOrEmpty(fileType) ? string.Empty : "\n" + ReadableStringHelper.FormatResourceString("PreviewTooltip_FileType", fileType);

            string dateModified = File.DateModified.ToString();
            imageTooltip += string.IsNullOrEmpty(dateModified) ? string.Empty : "\n" + ReadableStringHelper.FormatResourceString("PreviewTooltip_DateModified", dateModified);

            Size dimensions = await PropertyHelper.GetImageSize(File.Path);
            imageTooltip += dimensions.IsEmpty ? string.Empty : "\n" + ReadableStringHelper.FormatResourceString("PreviewTooltip_Dimensions", dimensions.Width, dimensions.Height);

            ulong bytes = await PropertyHelper.GetFileSizeInBytes(File.Path);
            string fileSize = ReadableStringHelper.BytesToReadableString(bytes);
            imageTooltip += string.IsNullOrEmpty(fileSize) ? string.Empty : "\n" + ReadableStringHelper.FormatResourceString("PreviewTooltip_FileSize", fileSize);

            OnPropertyChanged(nameof(ImageInfoTooltip));
        }
    }
}


Review comment (suggestion):
If you use an [ObservableProperty] for ImageTooltip, it would work without having to request manually OnPropertyChanged.

Code after:
        }

        private async Task UpdateImageTooltipAsync()
        {
            if (File == null)
            {
                return;
            }

            // Fetch and format available file properties
            var sb = new StringBuilder();

            string fileNameFormatted = ReadableStringHelper.FormatResourceString("PreviewTooltip_FileName", File.FileName);
            sb.Append(fileNameFormatted);

            string fileType = await PropertyHelper.GetFileType(File.Path);
            string fileTypeFormatted = string.IsNullOrEmpty(fileType) ? string.Empty : "\n" + ReadableStringHelper.FormatResourceString("PreviewTooltip_FileType", fileType);
            sb.Append(fileTypeFormatted);

            string dateModified = File.DateModified.ToString();
            string dateModifiedFormatted = string.IsNullOrEmpty(dateModified) ? string.Empty : "\n" + ReadableStringHelper.FormatResourceString("PreviewTooltip_DateModified", dateModified);
            sb.Append(dateModifiedFormatted);

            Size dimensions = await PropertyHelper.GetImageSize(File.Path);
            string dimensionsFormatted = dimensions.IsEmpty ? string.Empty : "\n" + ReadableStringHelper.FormatResourceString("PreviewTooltip_Dimensions", dimensions.Width, dimensions.Height);
            sb.Append(dimensionsFormatted);

            ulong bytes = await PropertyHelper.GetFileSizeInBytes(File.Path);
            string fileSize = ReadableStringHelper.BytesToReadableString(bytes);
            string fileSizeFormatted = string.IsNullOrEmpty(fileSize) ? string.Empty : "\n" + ReadableStringHelper.FormatResourceString("PreviewTooltip_FileSize", fileSize);
            sb.Append(fileSizeFormatted);

            ImageInfoTooltip = sb.ToString();
        }
    }
}