Hi,
we're creating tools for our ribbon dynamically using spring (www.springframework.net). The tools get registered on the toolbar manager right at creation and are added to groups by its keys.
Layout (image, size, caption, etc.) of the tools is provided while construction using decorators which implement functionality to set appropriate appearance properties, e.g. something like this
/// <summary> /// Decorates a tool /// </summary> /// <param name="tool">tool to decorate</param> public void Decorate(ITool tool) { ((ToolBase)tool).SharedProps.Caption = this.caption; }
Some of the tools are disabled upon creation using this technique:
/// <summary> /// Decorates a tool /// </summary> /// <param name="tool">tool to decorate</param> public void Decorate(ITool tool) { ((ToolBase) tool).SharedProps.Enabled = this.enabled; }
Fine. This works as expected. Now, sometime the we decide to activate the tools again at runtime, e.g. if in a list a item was selected. In our situation this means, that we activate all tools on a RibbonTab. We inherited from the RibbonTab and call the following function:
private void OnEnabledChanged(bool newValue) { this.enabled = newValue; foreach (RibbonGroup group in base.Groups) { foreach (var tool in group.Tools) { tool.SharedProps.Enabled = this.enabled; } } }
This activates all tools as expected. But, the first time I now click on a PopupControlContainerTool the tool gets deactivated and can not be accessed anymore until I again activate it (e.g. by selecting another item from the list as mentioned above).
Regards,
Michael
Michael,
Using the code you provided as a reference, I attempted to reproduce the behavior as described. Unfortunately, I could not reproduce the behavior of the PopupControlContainerTool becoming disabled when you click on it. Therefore, it seems the issue is either related to the version of the Infragistics being used, or processing within the application itself.
I have attached my sample application so you can reference it in hopes of finding a difference in our processing. If you happen to find the difference, and need help determining if its an issue within your application or a problem within our controls, please let me know. Additionally, if you have any other questions or information, feel free to reply.
Thanks,Chris
Dear Chris,
thanks for your fast reply. Unfortunately I cannot build the code, maybe because I have a different version (I get an error while resolving types in the licx file provided by you). I am running 8.3.20083.1009, is this the latest?
There are two things for you to do in order to allow the project to compile against your build of NetAdvantage.
If you don't want to perform these manual steps, you could always run Project Upgrade Utility, and upgrade to NetAdvantage 2008 Volume 3 which will update the project to use your build of the assemblies.
Let me know if you need any further assistance.
Thanks,
Chris
Chris,
thanks, second option was more my favour :-) I tested it and found the difference. As I told before, we add decorators to our tools to change visual style by configuration. The decoration of the tools is applied in InitializeFrom, but now, once the tool gets enabled, the decorators are again executed and so again the "disabled style" is applied.
I think the problem here is, that I do not really understand the toolbar architecture at all. What's all this with shared properties and instance properties and why can't I just add tools to groups and they are only "living" in that group? Sorry, this is very confusing.
The following article has sections named "Root Tools and Instance Tools" and "SharedProps and InstanceProps" which should help give you a better understanding of how it works: http://help.infragistics.com/Help/NetAdvantage/NET/2008.3/CLR2.0/html/WinToolbarsManager_Terms_and_Concepts.html
The reason why this is needed is so you can have multiple instances of a tool in different areas of your application and not have to write code so that each tool appears the same way or does the same thing when clicked.