How to display controls (like radwindow) at design time when noxaml is used and implicit style resources are in a custom dll

11 posts, 1 answers
  1. Peter
    Peter avatar
    6 posts
    Member since:
    Mar 2015

    Posted 11 Aug 2015 Link to this post

    I want to use Telerik implicit styles because this seems to be the favorite technique to use with Telerik controls. 

    So I use the Telerik noxaml dll's in my project.

    I have made a separate class library in which I have included the Telerik resources (the theme resource files). These resources are merged at startup (in the Application class) using code like

     

    Current.Resources.MergedDictionaries.Clear();
    Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
    {
        Source = new Uri("/libraryDll;component/Themes/System.Windows.xaml", UriKind.Relative)
    });

     

    When running the application all works fine and the radwindow is displayed and styled correctly.

    However, at design time I don't see anything. This is (of course) because at design time the xaml resources are not available (loaded).

     

    How do I fix this problem so I can see the telerik controls at design time? If you can't see the controls you can't design a window can you?

     

    Regards,
    Peter

     

  2. Kalin
    Admin
    Kalin avatar
    1360 posts

    Posted 12 Aug 2015 Link to this post

    Hi Peter,

    You could merge the same resource dictionaries in Application.Resources of App.xaml file in order to see the controls in the designer. Afterwards you can change the theme in code behind without a problem whenever needed:

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/libraryDll;component/Themes/System.Windows.xaml"/>
                <ResourceDictionary Source="/libraryDll;component/Themes/Telerik.Windows.Controls.xaml"/>
                <ResourceDictionary Source="/libraryDll;component/Themes/Telerik.Windows.Controls.Input.xaml"/>
                <ResourceDictionary Source="/libraryDll;component/Themes/Telerik.Windows.Controls.Navigation.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

    However if this is not helping, I would like to ask you to share some more details regarding the setup of the project. If you an open up support ticket with a sample project attached, we will be glad to check it on our side and provide you with a solution.

    I'm looking forward to hearing from you.

    Regards,
    Kalin
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. Peter
    Peter avatar
    6 posts
    Member since:
    Mar 2015

    Posted 12 Aug 2015 Link to this post

    Hi Kalin,

    This can work when I have an App available. But when developing a separate library (assembly/dll) in which I want to create user controls which use telerik controls, I don't have an App.xaml available (because it's a class library and not a wpf app).

    This means I am forced to always include a wpf project when I want to develop a class library that contains telerik controls and uses implicit styles? That's not very convenient.

    Regards,
    Peter

     

  4. Answer
    Kalin
    Admin
    Kalin avatar
    1360 posts

    Posted 13 Aug 2015 Link to this post

    Hi Peter,

    I'm sorry for misunderstanding. What I can suggest you would be to check the attached sample project that demonstrates how can use no xaml binaries in separate ControlLibrary project that don't have App.xaml and still have designer working. Basically the project uses approach similar to this one for embedding the Telerik assemblies in the control library. It includes adding the assemblies as embedded resources, a static TelerikThemeUtilities class and some AssemblyResolve work. This pretty much takes care of embedding the assemblies. When extracting the project just add the referenced binaries to the lib folder of the ControlLibrary project and let me know if

    Hope this will work for you.

    Regards,
    Kalin
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  5. Peter
    Peter avatar
    6 posts
    Member since:
    Mar 2015

    Posted 13 Aug 2015 in reply to Kalin Link to this post

    Hi Kalin,

    Thanks for the sample. It looks promising and I think it will do the trick. Adding one line (local:TelerikThemeUtilities.DesignTime="True") to each control seems doable.

    I will investigate this further and let you know.

    Regards,

    Peter

  6. Kalin
    Admin
    Kalin avatar
    1360 posts

    Posted 14 Aug 2015 Link to this post

    Hello Peter,

    Please check it and let us know if you have any further questions or concerns.

    Regards,
    Kalin
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  7. Peter
    Peter avatar
    6 posts
    Member since:
    Mar 2015

    Posted 18 Aug 2015 Link to this post

    Hi Kalin,

    Your suggested solution seems to work very well. Thanks :)

    Regards,
    Peter

  8. Kalin
    Admin
    Kalin avatar
    1360 posts

    Posted 18 Aug 2015 Link to this post

    Hi Peter,

    I'm glad the suggestion helped. If you have any other questions, let us know.

    Regards,
    Kalin
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  9. Raul
    Raul avatar
    37 posts
    Member since:
    Apr 2014

    Posted 05 Feb Link to this post

    Hello,

    I know, that this is an old thread. But this is the only one describing my situation.

    I'm using the described solution with the static class TelerikThemeUtilities since some years without trouble.

    Now I have to make some modifications on that project and have the problem that it no longer works on the new system (Windows 10 with VS 2019).

    I'm getting the message:

    "Object reference not set to an instance of an object"

    on the row:

    local:TelerikThemeUtilities.DesignTime="True"

    I copied the whole project to an other system and it runs there without problems. All the libs are added to the project. After spending the wohle day I was not able to detect the difference on both systems. One was that the older system runs VS 2017, but installing VS 2017 on the new system didn't help.

    Any ideas?

  10. Raul
    Raul avatar
    37 posts
    Member since:
    Apr 2014

    Posted 05 Feb Link to this post

    Sometimes it helps to post an issue...

    Just after posting it I renewed all Telerik references. Seems this has resolved the issue.

  11. Dinko
    Admin
    Dinko avatar
    1144 posts

    Posted 10 Feb Link to this post

    Hi Raul,

    We are happy to hear that your question has been resolved, and thank you for sharing the solution for it. If you have any other questions, you can open a new forum thread with your questions posted, and we will be happy to help.

    Regards,
    Dinko
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top