We have a windows application with around 50 forms. We are starting to use styling from infragistics. So we have converted a few controls of 5 forms into infragistics and some controls are still windows controls. We have prepared a style library which contains different stylesets for different forms. We have used the following function to add the styleSetName and StyleLibraryName property to all the controls in the form
public static void SetThemeProperties(Control control, String styleLibraryName, String styleSetName) { if (control != null) { PropertyDescriptorCollection tempObjectPropertyCollection = TypeDescriptor.GetProperties(control); PropertyDescriptor tempObjectStyleLibraryNameProperty = tempObjectPropertyCollection.Find("StyleLibraryName", true); PropertyDescriptor tempObjectStyleSetNameProperty = tempObjectPropertyCollection.Find("StyleSetName", true);
if (tempObjectPropertyCollection != null && tempObjectStyleLibraryNameProperty != null && tempObjectStyleSetNameProperty != null) { tempObjectStyleLibraryNameProperty.SetValue(control, styleLibraryName); tempObjectStyleSetNameProperty.SetValue(control, styleSetName); } if (control.Controls != null) { foreach (Control child in control.Controls) { SetThemeProperties(child, styleLibraryName, styleSetName); } } }
Now since the style library which is being loaded with an alias(styleLibraryName) so it does not affect other forms where the property is not set. But this also results in problem of inbox controls not being styled, since they do not have any styleSetName property. We already have dropped the InboxControlStyler on the forms.
Can you suggest some way by which we can apply the different styleSets to inbox controls on different forms.
Thanks I exposed a property for the inboxControlStyler's DefaultStyleSet and DefaultStyleLibraryName which worked perfectly.
I think you should be able to get the InboxControlStyle for the form by using the components property on the form. You might have to use reflection, but it looks like you are already doing that, so it should be a big deal.
Another option would be for you to add a property to your form that exposes the InboxControlStyler - maybe use a base form class so you could just check for the base class.
Cant it be done in some common function so that I do not have to hardcode the values in each form. Is there no way it is exposed so that it can be set.
Hi,
I think what you need to do is set the DefaultStyleLibraryName and DefaultStyleSetName properties on the InboxControlStyler itself.