Image Gradient in WinUI3

85 Views Asked by At

I want to make a gradient in a WinUI3 app. The gradient should start in the center of the image and should go down to the bottom, where the color should be the color behind the image. I would like to make it look like the gradient in the Microsoft Store.

 Here is the image of the gradient

1

There are 1 best solutions below

0
Katana On

i suggest you to use winUICommunity library there is a new control called OpacityMaskView https://github.com/winUICommunity/WinUICommunity?tab=readme-ov-file#opacitymaskview

here you can find docs: https://ghost1372.github.io/winUICommunityComponents/controls/opacityMaskView/

in your case:

<wuc:OpacityMaskView>
    <wuc:OpacityMaskView.OpacityMask>
        <LinearGradientBrush StartPoint="0.5,0.5" EndPoint="0.5,1">
            <GradientStop Color="#FFFFFFFF" Offset="0"/>
            <GradientStop Color="#00FFFFFF" Offset="1"/>
        </LinearGradientBrush>
    </wuc:OpacityMaskView.OpacityMask>
    <Image Source="Image.jpg" Stretch="Uniform"/>
</wuc:OpacityMaskView>