Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
My understanding is that BuiltInCategory.OST_Viewers is a category for Views. However, having an issue with casting the element as a View.
if (sourceElement.Category?.Id.IntegerValue == (int)BuiltInCategory.OST_Viewers)
{
TaskDialog.Show("News", "Its a view!");
View v = sourceElement as View;
if (v.ViewType == ViewType.Section)
{
TaskDialog.Show("News", "Its a section!");
}
if (v.ViewType == ViewType.Elevation)
{
TaskDialog.Show("News", "Its an Elevation!");
}
}
This code works by letting me know "It's a view!" but fails at letting me know if it is a section or an elevation. I get an exception saying can't cast Element as a View. (If I do the (View) cast at least, in the example above v is null)
The definition of insanity is doing the same thing over and over again and expecting different results
Solved! Go to Solution.