i have main window , inside main window, there's menu section (my program references materialdesigninxamltoolkit, guess doesn't matter question).
because program needs super flexibe , super extensible, menu items not defined via code. each menuitem based on namespace.name of 1 view, stored in database.
to open menuitem, there's action calls method, view open in tab item.
action ac = new action(() => open<xyz.maschine.verwaltungview>(item.bezeichnung));
(item.bezeichnung refers name displayed header in tab)
my problem xyz.maschine.verwaltung. it's fiexed reference view don't know @ point of time (plus seeems wrong create menu items fix). should filled in automatically, depending on menu item selected. tried many many things, 1 seems explain trying figure out:
string strac = item.namespacepassform + "." + item.passformview; action ac = new action(() => open<strac>(item.bezeichnung));
if need more details, i'll edit post , put more code.
you can't generic method, can like:
open(strac, item.bezeichnung)
and use type.gettype(strac) inside open method type string. strac have qualified class name though. once have type, can dynamically create object in various ways (reflection, expression trees, il, activator.createinstance, etc.).
Comments
Post a Comment