Create Custom Theme

6 posts, 2 answers
  1. Manas
    Manas avatar
    9 posts
    Member since:
    Apr 2011

    Posted 22 Apr 2011 Link to this post

    Hello there,
    I tried to follow the steps as described at the following link to create and use a Custom Theme for GridView but getting exception. I can provide the sample projects if you need it.

    http://www.telerik.com/help/silverlight/common-styling-apperance-themes-custom-theme-project-telerik-approach.html

    However I am getting the following exception on the InitializeComponent() of MainPage.xaml where I have a reference to RadGridView:

    ?e

    {System.Windows.Markup.XamlParseException: Set property 'System.Windows.FrameworkElement.Style' threw an exception. [Line: 12 Position: 30] ---> System.Windows.Markup.XamlParseException: Set property 'Telerik.Windows.Controls.Theme.ApplicationThemeSetter' threw an exception. [Line: 51 Position: 70] ---> System.Exception: Error HRESULT E_FAIL has been returned from a call to a COM component.

    at MS.Internal.XcpImports.CheckHResult(UInt32 hr)

    at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, String s)

    at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)

    at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)

    at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)

    at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)

    at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)

    at System.Windows.ResourceDictionary.set_Source(Uri value)

    at Telerik.Windows.Controls.Theme.CreateResourceDictionaryForApplicationTheme(Theme theme, String controlAssembly)

    at Telerik.Windows.Controls.Theme.AddMergedDictionaryFromApplicationTheme(ResourceDictionary generic, String assemblyName)

    at Telerik.Windows.Controls.Theme.OnApplicationThemeSetterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)

    at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)

    at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)

    at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)

    at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)

    at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)

    at Telerik.Windows.Controls.Theme.SetApplicationThemeSetter(DependencyObject obj, String value)

    --- End of inner exception stack trace ---

    at MS.Internal.XcpImports.CreateFromXaml(UnmanagedMemoryStream stream, String sourceAssemblyName, Boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers)

    at System.Windows.Controls.Control.GetBuiltInStyle(IntPtr nativeTarget, IntPtr& nativeStyle)

    --- End of inner exception stack trace ---

    at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)

    at TelerikSLCustomThemeClient.MainPage.InitializeComponent()

    at TelerikSLCustomThemeClient.MainPage..ctor()}

    [System.Windows.Markup.XamlParseException]: {System.Windows.Markup.XamlParseException: Set property 'System.Windows.FrameworkElement.Style' threw an exception. [Line: 12 Position: 30] ---> System.Windows.Markup.XamlParseException: Set property 'Telerik.Windows.Controls.Theme.ApplicationThemeSetter' threw an exception. [Line: 51 Position: 70] ---> System.Exception: Error HRESULT E_FAIL has been returned from a call to a COM component.

    at MS.Internal.XcpImports.CheckHResult(UInt32 hr)

    at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, String s)

    at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)

    at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)

    at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)

    at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)

    at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)

    at System.Windows.ResourceDictionary.set_Source(Uri value)

    at Telerik.Windows.Controls.Theme.CreateResourceDictionaryForApplicationTheme(Theme theme, String controlAssembly)

    at Telerik.Windows.Controls.Theme.AddMergedDictionaryFromApplicationTheme(ResourceDictionary generic, String assemblyName)

    at Telerik.Windows.Controls.Theme.OnApplicationThemeSetterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)

    at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)

    at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)

    at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)

    at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)

    at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)

    at Telerik.Windows.Controls.Theme.SetApplicationThemeSetter(DependencyObject obj, String value)

    --- End of inner exception stack trace ---

    at MS.Internal.XcpImports.CreateFromXaml(UnmanagedMemoryStream stream, String sourceAssemblyName, Boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers)

    at System.Windows.Controls.Control.GetBuiltInStyle(IntPtr nativeTarget, IntPtr& nativeStyle)

    --- End of inner exception stack trace ---

    at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)

    at TelerikSLCustomThemeClient.MainPage.InitializeComponent()

    at TelerikSLCustomThemeClient.MainPage..ctor()}

    Data: {System.Collections.ListDictionaryInternal}

    InnerException: {System.Windows.Markup.XamlParseException: Set property 'Telerik.Windows.Controls.Theme.ApplicationThemeSetter' threw an exception. [Line: 51 Position: 70] ---> System.Exception: Error HRESULT E_FAIL has been returned from a call to a COM component.

    at MS.Internal.XcpImports.CheckHResult(UInt32 hr)

    at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, String s)

    at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)

    at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)

    at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)

    at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)

    at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)

    at System.Windows.ResourceDictionary.set_Source(Uri value)

    at Telerik.Windows.Controls.Theme.CreateResourceDictionaryForApplicationTheme(Theme theme, String controlAssembly)

    at Telerik.Windows.Controls.Theme.AddMergedDictionaryFromApplicationTheme(ResourceDictionary generic, String assemblyName)

    at Telerik.Windows.Controls.Theme.OnApplicationThemeSetterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)

    at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)

    at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)

    at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)

    at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)

    at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)

    at Telerik.Windows.Controls.Theme.SetApplicationThemeSetter(DependencyObject obj, String value)

    --- End of inner exception stack trace ---

    at MS.Internal.XcpImports.CreateFromXaml(UnmanagedMemoryStream stream, String sourceAssemblyName, Boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers)

    at System.Windows.Controls.Control.GetBuiltInStyle(IntPtr nativeTarget, IntPtr& nativeStyle)}

    Message: "Set property 'System.Windows.FrameworkElement.Style' threw an exception. [Line: 12 Position: 30]"

    StackTrace: " at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)\r\n at TelerikSLCustomThemeClient.MainPage.InitializeComponent()\r\n at TelerikSLCustomThemeClient.MainPage..ctor()"


  2. Answer
    Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 22 Apr 2011 Link to this post

    Hi Manas,

     

    Can you verify that you have specified your custom theme in RadGridView's xaml file?:

    <local:MyTheme x:Key="Theme"/>


    You may find attached sample project that demonstrates this approach.
    Please check the sample and let me know how it differs from yours. 


    Greetings,
    Vanya Pavlova
    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
  3. Manas
    Manas avatar
    9 posts
    Member since:
    Apr 2011

    Posted 25 Apr 2011 Link to this post

    Thank you for the sample. The sample works fine. Also in my existing business application for a new xaml page the Custom Theme project works fine for the RadGridView. However I am getting exception on other existing xaml pages on the  InitializeComponent(); For example when I commented the RadDataPager reference on one of the usercontrol xaml that control's InitializeComponent() stopped giving me the ThemeSetter exceptions.

    BTW what does this mean?
    "You should have references to all assemblies that you are styling. Which means that if you have Style for RadMenu in your theme project, you should have a reference to the Telerik.Windows.Controls.Navigation.dll assembly in your application or you will get an exception."
    Is this saying that, if I am creating custom theme only for the RadGridView I need to have corresponding DLLs referred in the custom Theme project? 

    Exception details below:
    ?e
    {System.Windows.Markup.XamlParseException: Set property 'System.Windows.FrameworkElement.Style' threw an exception. [Line: 300 Position: 31] ---> System.Windows.Markup.XamlParseException: Set property 'Telerik.Windows.Controls.Theme.ApplicationThemeSetter' threw an exception. [Line: 36 Position: 67] ---> System.Exception: Error HRESULT E_FAIL has been returned from a call to a COM component.
       at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, String s)
       at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
       at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
       at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
       at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
       at System.Windows.ResourceDictionary.set_Source(Uri value)
       at Telerik.Windows.Controls.Theme.CreateResourceDictionaryForApplicationTheme(Theme theme, String controlAssembly)
       at Telerik.Windows.Controls.Theme.AddMergedDictionaryFromApplicationTheme(ResourceDictionary generic, String assemblyName)
       at Telerik.Windows.Controls.Theme.OnApplicationThemeSetterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
       at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at Telerik.Windows.Controls.Theme.SetApplicationThemeSetter(DependencyObject obj, String value)
       --- End of inner exception stack trace ---
       at MS.Internal.XcpImports.CreateFromXaml(UnmanagedMemoryStream stream, String sourceAssemblyName, Boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers)
       at System.Windows.Controls.Control.GetBuiltInStyle(IntPtr nativeTarget, IntPtr& nativeStyle)
       --- End of inner exception stack trace ---
       at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       at InventorySL.UserControls.OrdersView.InitializeComponent()
       at InventorySL.UserControls.OrdersView..ctor()}
        [System.Windows.Markup.XamlParseException]: {System.Windows.Markup.XamlParseException: Set property 'System.Windows.FrameworkElement.Style' threw an exception. [Line: 300 Position: 31] ---> System.Windows.Markup.XamlParseException: Set property 'Telerik.Windows.Controls.Theme.ApplicationThemeSetter' threw an exception. [Line: 36 Position: 67] ---> System.Exception: Error HRESULT E_FAIL has been returned from a call to a COM component.
       at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, String s)
       at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
       at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
       at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
       at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
       at System.Windows.ResourceDictionary.set_Source(Uri value)
       at Telerik.Windows.Controls.Theme.CreateResourceDictionaryForApplicationTheme(Theme theme, String controlAssembly)
       at Telerik.Windows.Controls.Theme.AddMergedDictionaryFromApplicationTheme(ResourceDictionary generic, String assemblyName)
       at Telerik.Windows.Controls.Theme.OnApplicationThemeSetterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
       at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at Telerik.Windows.Controls.Theme.SetApplicationThemeSetter(DependencyObject obj, String value)
       --- End of inner exception stack trace ---
       at MS.Internal.XcpImports.CreateFromXaml(UnmanagedMemoryStream stream, String sourceAssemblyName, Boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers)
       at System.Windows.Controls.Control.GetBuiltInStyle(IntPtr nativeTarget, IntPtr& nativeStyle)
       --- End of inner exception stack trace ---
       at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       at InventorySL.UserControls.OrdersView.InitializeComponent()
       at InventorySL.UserControls.OrdersView..ctor()}
        Data: {System.Collections.ListDictionaryInternal}
        InnerException: {System.Windows.Markup.XamlParseException: Set property 'Telerik.Windows.Controls.Theme.ApplicationThemeSetter' threw an exception. [Line: 36 Position: 67] ---> System.Exception: Error HRESULT E_FAIL has been returned from a call to a COM component.
       at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, String s)
       at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
       at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
       at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
       at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
       at System.Windows.ResourceDictionary.set_Source(Uri value)
       at Telerik.Windows.Controls.Theme.CreateResourceDictionaryForApplicationTheme(Theme theme, String controlAssembly)
       at Telerik.Windows.Controls.Theme.AddMergedDictionaryFromApplicationTheme(ResourceDictionary generic, String assemblyName)
       at Telerik.Windows.Controls.Theme.OnApplicationThemeSetterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
       at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at Telerik.Windows.Controls.Theme.SetApplicationThemeSetter(DependencyObject obj, String value)
       --- End of inner exception stack trace ---
       at MS.Internal.XcpImports.CreateFromXaml(UnmanagedMemoryStream stream, String sourceAssemblyName, Boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers)
       at System.Windows.Controls.Control.GetBuiltInStyle(IntPtr nativeTarget, IntPtr& nativeStyle)}
        Message: "Set property 'System.Windows.FrameworkElement.Style' threw an exception. [Line: 300 Position: 31]"
        StackTrace: "   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)\r\n   at InventorySL.UserControls.OrdersView.InitializeComponent()\r\n   at InventorySL.UserControls.OrdersView..ctor()"


  4. Answer
    Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 26 Apr 2011 Link to this post

    Hi Manas,

     

    Indeed you are right. When you are creating custom theme you have to create XAML file for all assemblies that you refer in your project. This means that you need to create Telerik.Windows.Controls.Input.xaml, Telerik.Windows.Controls.Navigation.xaml etc. files even if you don't add Styles there.
    We are them loading them when you instantiate control from corresponding assembly. Then as you mentioned
    you should have references to all assemblies that you are styling. Which means that if you have Style for RadMenu in your theme project, you should have a reference to the Telerik.Windows.Controls.Navigation.dll assembly in your application or you will get an exception.
    Regarding RadDataPager's case I believe that internally something went wrong. Feel free to send us a small application in a new support ticket where we can see what is going on.



    Kind regards,
    Vanya Pavlova
    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
  5. Krasimir
    Krasimir avatar
    15 posts
    Member since:
    Jan 2011

    Posted 13 Jan 2012 Link to this post

    Hello Telerik team,
    I have identical problem not with a custom theme but with Windows7 theme. Have you found any solution to this problem with the custom theme that maybe I can use with the default Windows7 theme? The problem occured when I upgradet to Silverlight 5!
  6. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 13 Jan 2012 Link to this post

    Hello Krasimir,

     

    We are not aware of an issue related to modifying built-in Telerik themes in Silverlight 5.
    May you please try to isolate the problem in a small runnable application with this theme and send it back to us as an attachment in a new support ticket? We will take a look at it and we would be able to provide you witn an appropiate solution.


    Greetings,
    Vanya Pavlova
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top