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

Problem setting theme for gauge in code-behind

1 Answer 76 Views
Gauge
This is a migrated thread and some comments may be shown as answers.
madladuk
Top achievements
Rank 2
madladuk asked on 11 Nov 2010, 06:20 PM
Hi all.

If I use the Office_Black theme I dont get a problem, however if I use a different theme, the quadrant gauge does not draw itself correctly [attached screen shot] obviously I am doing something stupid!

string uriString = "/Telerik.Windows.Controls.Gauge;Component/Themes/generic.xaml";
                if (!String.IsNullOrWhiteSpace(dashitem.theme))
                {
                    if (dashitem.theme != "Office_Black")
                    {
                        Regex regularExp = new Regex("/[^/]+xaml$");
                    uriString = regularExp.Replace( helper.GetThemeForControl(dashitem.theme).Source.OriginalString,
                                                   @"/Telerik.Windows.Controls.Gauge.xaml");
                    }
                }
  
                ResourceDictionary dictionary = new ResourceDictionary();
                dictionary.Source = new Uri(uriString, UriKind.Relative);
  
  
  
                string stylestring = null;
                switch (dashitem.componentguid.ToString().ToLower())
                {
                    case "ff5e5754-1552-4ad1-ac4e-eb8bad7481c8":
                        stylestring = "HalfCircleWStyle";
                        break;
                    case "1bbfac2f-335c-408e-8d25-079d79678059":
                        stylestring = "HalfCircleNStyle";
                        break;
                    case "ce2472de-ce75-47e9-81a7-be616d72cbce":
                        stylestring = "HalfCircleEStyle";
                        break;
                    case "8293bb3b-4d33-4b47-9db5-89094e179436":
                        stylestring = "HalfCircleSStyle";
                        break;
                    case "18e256e3-81c7-477c-ac19-6116dc159823":
                        stylestring = "QuarterCircleNEStyle";
                        break;
                    case "1995d93f-e974-46e6-9849-3d1f05baf062":
                        stylestring = "QuarterCircleSEStyle";
                        break;
                    case "15c7110b-072e-4502-806a-f1791ea6d77b":
                        stylestring = "QuarterCircleNWStyle";
                        break;
                    case "44a74f37-204f-4f5e-8501-22f53178c015":
                        stylestring = "QuarterCircleSWStyle";
                        break;
                }
                if (stylestring != null)
                {
                    // setup semicircular style to the gauge 
                    if (dictionary.Contains("RadialGauge" + stylestring))
                    {
                        gauge.Style = dictionary["RadialGauge" + stylestring] as Style;
                    }
                    // setup semicircular style to the scale 
                    if (dictionary.Contains("RadialScale" + stylestring))
                    {
                        scale.Style = dictionary["RadialScale" + stylestring] as Style;
                    
                }

if (!String.IsNullOrWhiteSpace(dashitem.theme))
               {
                   StyleManager.SetTheme(radGauge, helper.GetThemeForControl(dashitem.theme));
                   StyleManager.SetTheme(needle, helper.GetThemeForControl(dashitem.theme));
               }

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 16 Nov 2010, 12:57 PM
Hello madladuk,

When you setup a theme to the RadGauge then it could override style of the RadialGauge.
I would recommend to set a theme for RadGauge and RadialScale before setting styles to the RadialGauge and RadialScale elements.
I have attached a sample solution which changes theme by MouseLeftButtonDown event. I hope it helps.

Sincerely yours,
Andrey Murzov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Gauge
Asked by
madladuk
Top achievements
Rank 2
Answers by
Andrey
Telerik team
Share this question
or