Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
544 views
in Technique[技术] by (71.8m points)

c# - Xamarin.Forms 2.5.0 and Context

Today I updated to Xamarin.Forms 2.5.0 and saw, that I get the following warnings:

  • From the Android sub-project:

    Warning CS0618 'Forms.Context' is obsolete: 'Context is obsolete as of version 2.5. Please use a local context instead.'

How can I get the local context instead of Forms.Context? Is the Android Context meant?

  • From the custom renderer:

    Warning CS0618 'ButtonRenderer.ButtonRenderer()' is obsolete: 'This constructor is obsolete as of version 2.5. Please use ButtonRenderer(Context) instead.'

In my ButtonRenderer I only have the OnElementChanged() method, so what should I change here? Simply add a ButtonRenderer(Context) constructor? I still get the warning, if I do this in my platform renderer class. Does anyone have an example? The official documentation doesn't mention it and Google also doesn't bring some useful results, except the open source code of ButtonRenderer. This change also concerns many other renderer classes.

Does anyone had experienced other changes, which brakes plugins and so on?

PS: Also I didn't found out, when Device.Windows was deprecated. Now I replaced it with Device.UWP.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had this same issue for a SearchBarRenderer and all I needed to do to fix it was add a constructor like so:

public ShowSearchBarRenderer(Context context) : base(context)
{
}

Hope that answers the second part of your question.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...