Feeds:
Posts
Comments

Archive for August, 2008

I needed this for a current project.

Here’s a simple Linq query that returns all types from an assembly that derive from System.Windows.FrameworkElement

string aName = 
"PresentationFramework, Version=3.0.0.0, 
Culture=neutral, 
PublicKeyToken= 31bf3856ad364e35";
 Assembly assembly = Assembly.Load(aName);
 var q = from type in assembly.GetTypes()
  where type.IsSubclassOf(
       typeof(System.Windows.FrameworkElement))
  orderby type.Name
  select type;

ElementsListBox.ItemsSource = q.ToList();
ElementsListBox.DisplayMemberPath = "Name";

Read Full Post »