问题
I have a custom UI Editor for a property in C# . The editor works fine at design time. How ever I want to lauch the editor on click of a button at runtime. How can I do this?
Thanks, Datte
回答1:
Using a UITypeEditor
in custom (i.e. runtime) scenarios is definitely a trick proposition. The most obvious part about launching a UITypeEditor
is quite trivial: Just cast the instance to UITypeEditor
and call EditValue
or whatever other method you want.
One of the hardest parts about using them is figuring out what type descriptor context to provide, and harder yet, figuring out which services to provide.
The more you know about the particular editor you are trying to host the better you will know what context and service to provide.
What you're trying to do is definitely possible (obviously Visual Studio can do it), but it might be very difficult.
What have you tried so far and what isn't working?
回答2:
Here is an example I have: http://xacc.svn.sourceforge.net/viewvc/xacc/xacc/Controls/UIEditorForm.cs?revision=7&view=markup
来源:https://stackoverflow.com/questions/2047277/using-ui-editor-at-runtime-on-a-button-click