Problem:
Using code need to add the XAML x:Name property to my ShellContentItem, that I'm creating inside AppShell.
Screenshots:
CodePudding user response:
When adding an element in c#, you don't "create an x:Name". Instead, you simplify define a property, and set that property to the element.
private ShellContent myItem;
// Inside your method
myItem = new ShellContent();
...
Now you access myItem
like any other property.
If you wish to create and access a collection of items, you do that like any other kind of object in c#:
private List<ShellContent> myItems;
// In method.
myItems = new List<ShellContent>();
for (...)
{
var item = new ShellContent();
myItems.Add(item);
}
Now access one like any other list: myItems[...]
.