C
C#17mo ago
Ezekiel

❔ Question for when using XAML vs C#

Hello ! So I'm programming in video Games and recently I learned .NET MAUI which is really different with XAML. And to me it is confusing when to use. As I understand the best thing to do is to use it as often as possible but in some cases I don't know how to do so. Here is my example : I am doing some questionnaire creator and I want my user to chose as many options he wants for its question (like 5 radio buttons or 4). Then I want to instantiate all those buttons but I don't know what is the good practice. Like should I pass some parameter of number and then in my component constructor instantiate the good amount ? Or is there some XAML possibility to know how much of the same item it has to display ? Or should I just create a stackPannel and add as many component as needed in my RelayCommand ? Thank you for your help, it is highly appreciated.
3 Replies
Angius
Angius17mo ago
Generally, you send data from C# and the XAML layer generates all the controls needed For example, you can have a lost of objects, and bind it to a listbox Then, in that listbox, define the controls that will be used to display each item from the binded list
Ezekiel
EzekielOP17mo ago
Thank you for your help !
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server