Hello,
I'm able to set the background color of the layout control by setting its BackColor property to a Color value but I can't find a way to reset the background color to the Theme's default. The Method ResetValue() is not available for RadLayoutControl.
Any help would be appreciated!
Thanks
Jürgen
6 Answers, 1 is accepted
Only RadElements have the ResetValue method. In this case, you can set the color of the root element:
private
void
radButton1_Click(
object
sender, EventArgs e)
{
radLayoutControl1.RootElement.BackColor = Color.Red;
}
private
void
radButton2_Click(
object
sender, EventArgs e)
{
radLayoutControl1.RootElement.ResetValue(RadItem.BackColorProperty, ValueResetFlags.Local);
}
I hope this will be useful. Let me know if you have additional questions.
Regards,
Dimitar
Progress Telerik

Hello Dimitar,
Thanky you very much for your quick answer! Unfortunatelly your advise doesn't work. Any other suggestion would be much appreciated!
Thanks
Jürgen
By the way: I use version 2016.3.1024.40.
I have tested this with the specified version and it still works. I have attached my test project. Could you please check it and let me know how it differs from your real setup?
Thank you in advance for your patience and cooperation.
Regards,
Dimitar
Progress Telerik

Hello Dimitar,
Thank you very much for your test project! It works but only with the default theme. When I set a specific theme (in my example Offive2010black) it doesn't work anymore. This is the modified code of your test project I used for my test:
public partial class RadForm1 : Telerik.WinControls.UI.RadForm
{
public RadForm1()
{
InitializeComponent();
ThemeResolutionService.ApplicationThemeName = "Office2010Black";
}
private void radButton1_Click(object sender, EventArgs e)
{
radLayoutControl1.BackColor = Color.Red;
// radLayoutControl1.RootElement.BackColor = Color.Red;
}
private void radButton2_Click(object sender, EventArgs e)
{
radLayoutControl1.RootElement.ResetValue(RadItem.BackColorProperty, ValueResetFlags.Local);
}
}
Thanky again for your help!
Regards,
Jürgen
When the color of the root element is set all elements that do not have another color explicitly set will inherit the color from the root element. In this case, the ContainerElement is explicitly setting the BackColor and this is why there is no effect. So you need to change the BackColor of the ContainerElement:
private
void
radButton1_Click(
object
sender, EventArgs e)
{
radLayoutControl1.ContainerElement.BackColor = Color.Red;
}
private
void
radButton2_Click(
object
sender, EventArgs e)
{
radLayoutControl1.ContainerElement.ResetValue(RadItem.BackColorProperty, ValueResetFlags.Local);
}
I hope this will be useful.
Regards,
Dimitar
Progress Telerik

Hello Dimitar,
with the changes you suggested it works now as expedted. Thanks again for your well-founded support!
Regards,
Jürgen