This is a migrated thread and some comments may be shown as answers.

Editing template of RadComboBox inside RadPropertyGrid

9 Answers 251 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 11 Mar 2013, 09:24 PM
Hi,

I have a control template that needs to be applied to all of my combo boxes in my project, including those in the property grid I have. I am using the Editable and and noneditable template to get the style that I am looking for. My property grid uses items such as textboxes, checkboxes, datetimepickers, and comboboxes. Is there a way to apply the same control template to all combo boxes that appear in my propertygrid?

Thanks

9 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 12 Mar 2013, 11:58 AM
Hello,

May I ask you, which version of RadControls you are currently using? With Q1 2013 we have added a DataFieldLoaded event, so that you can subscribe to it and set the respective style to the desired ComboBox instance, which is the field's Content.

All the best,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Michael
Top achievements
Rank 1
answered on 12 Mar 2013, 03:22 PM
Hi

Thanks for the response. I am using 2013 Q1, but I could only find FieldLoaded. It still worked fine. 
private void RadPropertyGrid_FieldLoaded(object sender, Telerik.Windows.Controls.Data.PropertyGrid.FieldEventArgs e)
        {
            if (e.Field.Content is Telerik.Windows.Controls.RadComboBox)
            {
                Telerik.Windows.Controls.RadComboBox cb = e.Field.Content as Telerik.Windows.Controls.RadComboBox;
                cb.SetResourceReference(Telerik.Windows.Controls.RadComboBox.NonEditableTemplateProperty, "NonEditableTemplate");
                cb.SetResourceReference(Telerik.Windows.Controls.RadComboBox.EditableTemplateProperty, "EditableTemplate");
                SolidColorBrush blue = new SolidColorBrush();
                blue.Color = Color.FromArgb(255,58,85,101);
                cb.Foreground = blue;
            }
            if (e.Field.Content is Telerik.Windows.Controls.RadDateTimePicker)
            {
                Telerik.Windows.Controls.RadDateTimePicker dtp = e.Field.Content as Telerik.Windows.Controls.RadDateTimePicker;
                SolidColorBrush blue = new SolidColorBrush();
                blue.Color = Color.FromArgb(255, 58, 85, 101);
                dtp.Foreground = blue;
            }
        }
0
Ivan Ivanov
Telerik team
answered on 12 Mar 2013, 03:48 PM
Hi,

Yes, it is actually FieldLoaded. Sorry, it seems that I have not learned the changes in the API by heart yet :)

Regards,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kristoffer
Top achievements
Rank 1
answered on 11 Apr 2013, 11:37 AM
Can you please show an example of the use of this DataFieldLoaded event? I want to change the style of the comboboxes/textboxes of my auto-generated property grid items!
0
Maya
Telerik team
answered on 15 Apr 2013, 07:13 AM
Hi Kristoffer,

In order to update a property of an editor of the field, you can try something like:

private void RadPropertyGrid_FieldLoaded(object sender, Telerik.Windows.Controls.Data.PropertyGrid.FieldEventArgs e)
        {
            var textBox = e.Field.Content as TextBox;
            if (textBox != null)
            {
                textBox.FontSize = 20;
            }
        }
 

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kristoffer
Top achievements
Rank 1
answered on 03 Jun 2013, 02:12 PM
Thanks Maya! That did the trick :)

But... what if I want comboboxes to be transparent? This won't work:
if (e.Field.Content is RadComboBox)
{
    var comboBox = e.Field.Content as RadComboBox;
    comboBox.Background = null;
}

0
Maya
Telerik team
answered on 03 Jun 2013, 03:25 PM
Hi Kristoffer,

You can set the background to be transparent:

private void propertyGrid_FieldLoaded(object sender, FieldEventArgs e)
        {
            var comboBox = e.Field.Content as RadComboBox;
            if (comboBox != null)
            {
                comboBox.Background = new SolidColorBrush(Colors.Transparent);
            }
        }

But since there are elements underneath, you might not get the color you want. What is the behavior that you want to achieve ?  

Regards,
Maya
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kristoffer
Top achievements
Rank 1
answered on 03 Jun 2013, 03:28 PM
I'm simply trying to style the comboboxes of the property grid. Setting the background to transparent doesn't help as it is already transparent (I looked at your templates). However, by duplicating your templates and modifying it, I managed to create what I want; a transparent combobox.
0
Maya
Telerik team
answered on 03 Jun 2013, 03:33 PM
Hi Kristoffer,

Indeed, the proper way to go is to create style for RadComboBox instead. Do you have any troubles with the implementation ?  

Regards,
Maya
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PropertyGrid
Asked by
Michael
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Michael
Top achievements
Rank 1
Kristoffer
Top achievements
Rank 1
Maya
Telerik team
Share this question
or