Reputation: 51
so i have an object "Tabs" that i would to read the properties of. in this case, we have a count of 3, so there are 3 tabs. specifically trying to get the HeaderText property of the very first tab [0], as seen below:
i tried the following (based on the screenshot provided, you can see the name of the field is [0]:
var item = tabs.GetType().GetProperty("[0]").GetValue(tabs);
but i ended up with the error:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
here is the code im working with:
private void HeaderWasTapped(object sender, ItemHeaderTappedEventArgs e)
{
var PanelMap = new Controls.FlexMap();
var items = sender.GetType().GetProperty("Items").GetValue(sender);
// Reading non-public member of object
var tabs = items.GetType()
.GetField("tabItems", BindingFlags.Instance | BindingFlags.NonPublic)
.GetValue(items);
var item = tabs.GetType().GetProperty("[0]").GetValue(tabs);
// and some conditions here based on value of HeaderText
}
here is the type of var "Tabs":
System.Collections.Generic.List`1[DevExpress.Maui.Controls.TabViewItem]
not sure how to get the HeaderText here...
Upvotes: 0
Views: 31