How to use CustomRenderer for a single ContentPage in Xamarin.iOS and Xamarin.Android

I need to change the height of the Progress bar but just for a specific ContentPage, not for all my ContentPage's. I got the code where i change the progress bar height:

public class CustomProgressBarRenderer : ProgressBarRenderer
{
    protected override void OnElementChanged(
    ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
    {
        base.OnElementChanged(e);

        Control.ProgressTintColor = Color.FromRgb(0, 0, 0).ToUIColor();// This changes the color of the progress
    }


    public override void LayoutSubviews()
    {
        base.LayoutSubviews();

        var X = 1.0f;
        var Y = 10.0f; // This changes the height

        CGAffineTransform transform = CGAffineTransform.MakeScale(X, Y);
        Control.Transform = transform;
    }
}

i'd like to know if it is really possible. Thanks in advance.



Read more here: https://stackoverflow.com/questions/66320448/how-to-use-customrenderer-for-a-single-contentpage-in-xamarin-ios-and-xamarin-an

Content Attribution

This content was originally published by Gabriel Juren at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: