I'm using themes in my app with SkinManager.ApplicationVisualTheme("HighContrastBlack"). How can I apply the colors of the theme to my own UserControls?
For doing this, I need a way to get the colors of the HighContrastBlack Theme like "Background", "Text Color", "Selected Background", "Selected Text", "Button Background", "Button Text", "Hyperlink Color" and "Disabled Text".
I want to use the colors, to colorize my UserControl.
Additional, I would like to create my own themes, based on the HighContrastBlack theme and import them. Then I need the self configured colors from the by the Theme Studio exported .dll file.
Hi Nils Hoyer,
We have prepared the sample to achieve your requirement to apply the theme colors to Custom UserControl. Please find the sample below.
Please check the sample. If we misunderstood the query, please provide more details about the requirement, or modify our sample and revert to us. So, it will be helpful to prompt the solution on further.
Regards,
Sudharsan
I'm sorry, I posted in the wrong forum. I'm using WinForms, not WPF.😪
Nils Hoyer,
We are currently
analyzing your reported scenario. We need time to validate the scenario, we
will provide an update on or before November 10, 2023.
Regards,
Santhosh.G
Nils Hoyer,
We have prepared the
sample to meet your requirement of applying the theme to Custom UserControl.
Please find the sample below.
We would like to inform you that we do not have an implementation to set the theme for the entire application and we also do not set the theme for framework controls.
To set the theme for
a user control, you must implement Syncfusion-related controls in your user
control.
Here we have attached the tested sample
. Please have a look at this. If you have further query please provide details
or modify the attached sample based on your scenario. It will be helpful for us
to proceed further.
You misunderstood me. Your example shows, how to add a Syncfusion control into my UserControl.
But I have UserControls with my own paint method, based on System.Drawing.Graphics.
To draw them in the
HighContrastBlack
theme colors, I need to know them.
Hi Nils Hoyer,
If you're using controls from the Syncfusion library, you can easily set and apply themes to those controls. However, when it comes to user controls that are not part of the Syncfusion library, the functionality to apply themes directly to these controls might not be available, so it's not possible to apply themes to any other user controls.
Regards,
DhivyaBharathi Dakshinamurthy
Thank you for your answer.
Maybe you can implement a solution for this?
Hi Nils Hoyer,
We are implementing theme support for our controls at the source level. however, providing theme support for custom controls was not possible.
Regards,
Swathi D
I did not ask you to implement theme support for custom controls. Indeed, you can't do this.
But if you offer a way for me to get the theme colors, since I asked about in this thread, I would be able to do this.
So once again: Can you implement a solution, that I can get the theme colors of the selected theme?
Hi Nils Hoyer,
We have used the colors in our control themes that are based on System HighContrast themes. Please refer the attached picture, and we suggest you try using them in your case as well.
Regards,
Madhavan S
Yes, indeed, I can use hard-coded colors. But if you change your theme in the future or if I use another of your themes, I have to change my code again.
Why don't you understand, that this is a bad solution?
Why don't you want to implement a good solution into your software?
Nils Hoyer,
We kindly inform you that we don't have direct color
implementation for the themes. Instead, we maintain the colors as specified in
the control. For example, if you use SfButton in your application with the
theme set to "HighContrastBlack," based on the theme, we maintain the
colors in the SfButton control, such as "PressedBackColor" being
light gray and "BorderColor" being black.
We maintain the color on a control-by-control basis. For
your reference, please find the below code snippet.
|
<Properties Font="Microsoft San Serif;8.25;Regular" /> <Elements BackColor="#000000" DisabledBackColor="#000000" HoverBackColor="#00EFFF" PressedBackColor="#00EFFF" FocusedBackColor="#000000" ForeColor="#FFFFFF" HoverForeColor="#000000" PressedForeColor="#000000" FocusedForeColor="#FFFFFF" DisabledForeColor="#00F800" BorderColor="#FFFFFF" HoverBorderColor="#00EFFF" PressedBorderColor="#00EFFF" DisabledBorderColor="#00F800" FocusedBorderColor="#00EFFF"> </Elements> |
I found the answer to my question: I need to create the control, I want to get the colors from. For example, your SfButton. After creating it, I can access to his colors, like BackColor, DisabledBackColor, HoverBackColor and so on of your snippet with this code:
var sfButton = new SfButton();var backColor = sfButton.Style.BackColor;
var disabledBackColor = sfButton.Style.DisabledBackColor;
var hoverBackColor = sfButton.Style.HoverBackColor;
So the answer to my question is very simple, but you were not able to give it.
I found the colors, I want to use, except the "Hyperlink Color", configurable in the High Contrust Black theme.
Which control does it use?
Nils Hoyer,
Based on our
understanding, you intended to use those colors, except for the 'HyperLink
color.' For your information, we haven't disabled the 'HyperLink color' option;
this one is the default setting. The hyperlink
color is only applied to hyperlink text, such as in the Theme Studio
grid control, which contains hyperlink text in the Url column. When you set the
hyperlink color to white, it doesn't make any difference in your
application.
please refer the document