Home > Mobile >  Image was not loaded sometimes properly from Assets folder in UWP?
Image was not loaded sometimes properly from Assets folder in UWP?

Time:12-23

I have my OwnControl(userControl).In that control,I have an Image element(RangeSelectionIcon). I had created 3 new object for this UserControl and added this control to my StackPanel in my Page.The image won't be loaded properly to all 3 userControls.Most of the times,the image loaded for only one control and the other two was not loaded.The image path was also given correctly. I don't know what the issue was ? My complete project enter image description here

CodePudding user response:

Image was not loaded sometimes properly from Assets folder in UWP?

We can reproduce your problem, it looks SvgImageSource was not rendered correctly. for this scenario, we have a workaround that RasterizePixel and re-rendered svg. during the testing, it could work well, please refer the following code.

<Style x:Key="RangeSelectionIconStyle" TargetType="Image">
    <Setter Property="Width" Value="20" />
    <Setter Property="Height" Value="20" />
    <Setter Property="Margin" Value="6,5,6,0" />
    <Setter Property="Source">
        <Setter.Value>
            <SvgImageSource
                RasterizePixelHeight="20"
                RasterizePixelWidth="20"
                UriSource="ms-appx:///Assets/SelectRange.svg" />
        </Setter.Value>
    </Setter>
</Style>
  • Related