Problem setting theme for gauge in code-behind

2 posts, 0 answers
  1. madladuk
    madladuk avatar
    126 posts
    Member since:
    Dec 2009

    Posted 11 Nov 2010 Link to this post

    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,
                    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";
                        case "1bbfac2f-335c-408e-8d25-079d79678059":
                            stylestring = "HalfCircleNStyle";
                        case "ce2472de-ce75-47e9-81a7-be616d72cbce":
                            stylestring = "HalfCircleEStyle";
                        case "8293bb3b-4d33-4b47-9db5-89094e179436":
                            stylestring = "HalfCircleSStyle";
                        case "18e256e3-81c7-477c-ac19-6116dc159823":
                            stylestring = "QuarterCircleNEStyle";
                        case "1995d93f-e974-46e6-9849-3d1f05baf062":
                            stylestring = "QuarterCircleSEStyle";
                        case "15c7110b-072e-4502-806a-f1791ea6d77b":
                            stylestring = "QuarterCircleNWStyle";
                        case "44a74f37-204f-4f5e-8501-22f53178c015":
                            stylestring = "QuarterCircleSWStyle";
                    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));

  2. Andrey
    Andrey avatar
    1681 posts

    Posted 16 Nov 2010 Link to this post

    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
Back to Top