雨田博客
让斗志、坚持、自信成为习惯

导航

 
//获得类所在的程序集名称(此处我选择当前程序集)
string bllName = System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().Location);

//获得类名(我此处是提前写入Button的Name属性)
string className = (sender as Button).Name;

//获得类全名,格式:WpfApplication.ToggleButton
string fullClassName = bllName + "." + className; 

//根据类名称创建类实例
var bllObject = System.Reflection.Assembly.Load(bllName).CreateInstance(fullClassName);

  

posted on 2016-03-18 09:45  张雨田  阅读(2350)  评论(0编辑  收藏  举报