public MainPage() { InitializeComponent(); var model = new MainPageModel(Navigation); BindingContext = model; #region Set left icon on button (usin a svg) var svgRefresh = new SvgImageSource { Svg = "res:images.refresh", Height = 15 }; //ColorMapping = "ffffff=00ff00" //FileImageSource imageThatCanBeUsedInTabsWithACustomTabRenderer = svgRefresh.Image; ColorMappingSelectedButton.Image = svgRefresh.CreateFileImageSource(); #endregion model.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(MainPageModel.Zoom) || args.PropertyName == nameof(MainPageModel.Translation)) { var emptyZoom = Math.Abs(model.ZoomValue) < float.Epsilon; var emptyPan = model.Translation.IsEmpty; if (emptyZoom && emptyPan) { TheSvg.ViewportTransform = null; } else { var matrixFinal = DependencyService.Get <IMatrixFactory>().Create(); if (!emptyPan) { var matrix = DependencyService.Get <IMatrixFactory>().Create(); var innerSize = TheSvg.InnerSize; var translation = model.Translation; matrix.Translate( (float)(-translation.X * innerSize.Width / (TheSvg.Width * model.ZoomValue)), (float)(-translation.Y * innerSize.Height / (TheSvg.Height * model.ZoomValue))); matrixFinal.Concat(matrix); } if (!emptyZoom) { //Rotation whose pivot point is at center var matrix1 = DependencyService.Get <IMatrixFactory>().Create(); matrix1.Scale((float)(1 / model.ZoomValue), (float)(1 / model.ZoomValue)); var innerSize = TheSvg.InnerSize; var matrix0 = DependencyService.Get <IMatrixFactory>().Create(); matrix0.Translate(-(float)(innerSize.Width / 2), -(float)(innerSize.Height / 2)); var matrix2 = DependencyService.Get <IMatrixFactory>().Create(); matrix2.Translate((float)(innerSize.Width / 2), (float)(innerSize.Height / 2)); matrix1.Concat(matrix0); matrix2.Concat(matrix1); matrixFinal.Concat(matrix2); } TheSvg.ViewportTransform = matrixFinal; } } }; }