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

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

10 Answers 195 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 11 Aug 2015, 08:25 PM

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

 

10 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 12 Aug 2015, 10:18 AM
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
0
Peter
Top achievements
Rank 1
answered on 12 Aug 2015, 06:44 PM

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

 

0
Accepted
Kalin
Telerik team
answered on 13 Aug 2015, 08:22 AM
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
0
Peter
Top achievements
Rank 1
answered on 13 Aug 2015, 08:44 PM

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

0
Kalin
Telerik team
answered on 14 Aug 2015, 06:33 AM
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
0
Peter
Top achievements
Rank 1
answered on 18 Aug 2015, 12:13 PM

Hi Kalin,

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

Regards,
Peter

0
Kalin
Telerik team
answered on 18 Aug 2015, 12:49 PM
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
0
Raul
Top achievements
Rank 1
answered on 05 Feb 2020, 03:04 PM

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?

0
Raul
Top achievements
Rank 1
answered on 05 Feb 2020, 03:55 PM

Sometimes it helps to post an issue...

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

0
Dinko | Tech Support Engineer
Telerik team
answered on 10 Feb 2020, 11:58 AM

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.
Tags
General Discussions
Asked by
Peter
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Peter
Top achievements
Rank 1
Raul
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Share this question
or