Reputation: 678
What I am looking to do is create a list of all the WPF controls that ship with .NET 4. Ideally, this list would need to be a collection of string objects of items like "Button", "ListBox" etc.
Any help would be much appreciated!
Kris
Upvotes: 0
Views: 95
Reputation: 292695
This will retrieve all subclasses of FrameworkElement
in the PresentationFramework
assembly
var query =
from type in typeof(FrameworkElement).Assembly.GetTypes()
where type.IsSubclassOf(typeof(FrameworkElement))
select type.Name;
List<string> controls = query.ToList();
Note: there isn't a very clear definition of what is a "control" in WPF... there is a Control
class, but not all UI elements inherit from it. Most "controls" inherit (directly or indirectly) from FrameworkElement
.
Upvotes: 4
Reputation: 31192
var names = typeof(FrameworkElement)
.Assembly
.GetExportedTypes()
.Where(x => x.IsSubclassOf(typeof(FrameworkElement)))
.Select(x => x.Name);
Upvotes: 0
Reputation: 65166
If you really want all of them, you could search through the relevant assemblies using reflection and find any concrete classes that inherit from the control base class.
Upvotes: 0