Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Need help with Dynamics Objects on xamarin forms

CHAOS55CHAOS55 GTMember

Hi.
Can someone tell me, how i can create dynamics objects whith an ID for each object in xamarin forms.
What i need to do is a questionary but i dont know how many question would be on it.

Untill now i have found this options:

Option 1:
Create all posible objets in the questionary and make invisble the ones i dont need.

Option 2:
Create the objects in a class layout and dont make the instance of the ones i dont need (this is esencial the same thing :/ )

Can someone tell me if there´s a way i can create dynamics objects
Thanx!
:smiley:

Answers

  • CHAOS55CHAOS55 GTMember

    @WinterCloud Can you help me with this please?

    Thanx.

  • Jesse_JiangJesse_Jiang USMember ✭✭✭

    You can use AutomationId to do that

  • LuisRodrigoLuisRodrigo USMember

    Hi,
    @JesseJiang I had considered use it, I try something like this

    layout.Children.Add(new Button { AutomationId=ID.ToString(), Text = "Button"+ID.ToString(), ClassId=ID.ToString() });

    and with this I can create as many objects I need, but how can I control the action of the objects after them are created or its possible to change some properties after the object is created.

    Thanx

  • WinterCloudWinterCloud GBMember ✭✭✭

    What I can suggest is you keep two collection of objects, one is source, has all objects; and the other one is visible to users. and based on config/setting/user selection etc, you refill the user visible collection from the filtered source collection.

  • NMackayNMackay GBInsider, University admin
    edited April 2017

    +1 for solution suggested by @WinterCloud

    I've used a similar approach in a modular Prism mobile app, when the modules are discovered they notify an injected module service of what dynamic widgets/navigation actions each module has and are added into known action collections, the UI binds to seperate user widgets/navigation action collections based on security rights.

    This approach works very well.

Sign In or Register to comment.