none
[CS]Cannot Assign Enumeration to Button.Tag in Xamarin.Android Project RRS feed

  • Question

  • I have a Xamarin.Android project that contains a Button and a C# enum. I want to assign a value from this enum to the Tag property of the Button (and as you may know, the Tag property is of type Java.Lang.Object). I have the following code:

    this.btnReturnToGameOk.Tag = ReturnToGameStatus.AllowNegative;

    However, this give the following error:

    Cannot implicitly convert type 'ScorePadBlank_Testing.ReturnToGameStatus' to 'Java.Lang.Object'

    Isn't anything supposed to be allowed to be converted to an Object? I know that Java.Lang.Object is not exactly the same as .NET's System.Object, but I always thought that the purpose of the Tag property was to be allowed to store any temporary associated data. And an enum is a very basic type (with a very basic underlying type as well). What should I do? Thanks.


    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    • Moved by CoolDadTx Wednesday, January 15, 2020 2:53 PM Xamarin related
    Tuesday, January 14, 2020 10:35 PM

All replies

  • Hello,

    See the following

    https://stackoverflow.com/questions/49045763/set-tag-value-in-xaml


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, January 15, 2020 1:41 AM
  • The page you mention is about Xamarin.Forms and Xaml. I am talking about Android Native (Xamarin.Android) and C# (the codebehind).

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Wednesday, January 15, 2020 2:54 AM
  • Hi Nathan Sokalski,

    Thank you for posting here.

    Since this thread is related to Xamarin, I suggest that you can go to the Xamarin Community Forums to ask this question, they can provide more professional opinions and suggestions.

    The Visual C# forum discusses and asks questions about the C# programming language, IDE, libraries, samples, and tools.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 15, 2020 5:16 AM