Reputation: 2683
I have x ListViews
in my xaml Form:
lvExt1
lvExt2
In my program I can access them directly with lvExt1.Items
or similar.
I would like to access those within a function that has the number as parameter
Something like:
privat void accessListView(string number){
return lvlExt"number".Items;
}
In Symfony (PHP) I can do it like this: https://stackoverflow.com/a/31142123/1092632
I do realize it may be something completely different, but only to express what I am trying to do.
Upvotes: 0
Views: 1148
Reputation: 588
Two ways:
Use the way that WPF provided:
var lvlExt = this.FindName("lvlExt" + number) as ListView;
var lvlExt = LogicalTreeHelper.FindLogicalNode(this, "lvlExt" + number);
Use an array to reference:
var lvlExts = new ListView[3];
...
var lvlExt =ListView[number];
Upvotes: 1