Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

View Size in Custom Renderer

$
0
0

Hi
I'm trying to create a custom renderer for an Image in my iOS project. The problem is that I can't get any size information. The only thing I get is (see comment in code). I need the correct width and height when I re-create the image in the Blur function.

[assembly: ExportRenderer(typeof (BlurredImage), typeof (BlurredImageRenderer))]
...
 public class BlurredImageRenderer : ImageRenderer {
        protected override void OnElementChanged(ElementChangedEventArgs<Image> e) {
            base.OnElementChanged(e);

            var image = Control.Image;
            var width = Element.Width; // Returns -1
            var height = Element.Height; //Returns -1
        var size = image.Size; // Returns width=100, height=100 which is not the size of the image...???

            Control.Image = Blur(image, 1f);

        }

       ...
}

Am I doing this to early, before any size information is set?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>