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

Applying theme on only one page

5 Answers 222 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Kourosh
Top achievements
Rank 1
Kourosh asked on 02 Jun 2018, 05:17 AM

Hi,

How can I put the theme on only one page of my application without adding ResourceDictionary in App.xaml.

I don't want the theme to change the look of my whole application.

Best Regards

Kourosh

5 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 05 Jun 2018, 03:55 PM
Hello Kourosh,

My understanding is that you want to change the theme of a System.Windows.Controls.Page. Feel free to correct me if that is not the case and provide some more details about your specific scenario. 

If that is the case you should be able to achieve this by merging all of the required dictionaries for the theme in the Page's Resources collection instead of doing that in App.xaml.

I hope you find this helpful.

Regards,
Vladimir Stoyanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Kourosh
Top achievements
Rank 1
answered on 09 Jun 2018, 06:58 AM

Hello Vladimir,

Thank you for your reply.

You are correct, if I wanted to change all my pages, so I would use app.xaml and merged dictionaries. When I do so my problem is that the rest of my application's pages' appearance change. And this is what I do not want!

I don't want app.xaml to change the rest of the pages in my program.

I just want my ganttview page to have the windows7 look for example.

How do I do that?

Best Regards

kourosh

 

0
Accepted
Vladimir Stoyanov
Telerik team
answered on 13 Jun 2018, 10:50 AM
Hello Kourosh,

I am attaching a sample project which demonstrates how you can merge the needed files in only a certain page of the application. Please take a look at it and let me know if this is what you had in mind. Please note that the approach demonstrated in the attached project assumes that you are using the NoXaml UI for WPF binaries.

If you are using the Xaml dlls, you can set the telerik:StyleManager.Theme attached property on the desired control to the theme that you want. Here is an example:
<telerik:RadButton telerik:StyleManager.Theme="Expression_Dark"  />

Regards,
Vladimir Stoyanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Kourosh
Top achievements
Rank 1
answered on 18 Jun 2018, 10:46 AM

Hello Vladimir,

Thank you so much for your reply. Problem is solved thanks to your guidance sir :)

I have also found another solution in case someone else wanted it:

I put below code in mywindow or user controllers xaml:

<Window.Resources>
        <Style
            x:Key="TelerikStyle"
            TargetType="{x:Type FrameworkElement}">
            <Setter Property="telerik:StyleManager.Theme" Value="{x:Static telerik:StyleManager.ApplicationTheme}" />
        </Style>
        <Style
            BasedOn="{StaticResource TelerikStyle}"
            TargetType="{x:Type Button}" />
        <Style
            BasedOn="{StaticResource TelerikStyle}"
            TargetType="{x:Type CheckBox}" />
        <Style
            BasedOn="{StaticResource TelerikStyle}"
            TargetType="{x:Type ListBox}" />
        <Style
            BasedOn="{StaticResource TelerikStyle}"
            TargetType="{x:Type PasswordBox}" />
        <Style
            BasedOn="{StaticResource TelerikStyle}"
            TargetType="{x:Type RadioButton}" />
        <Style
            BasedOn="{StaticResource TelerikStyle}"
            TargetType="{x:Type RepeatButton}" />
        <Style
            BasedOn="{StaticResource TelerikStyle}"
            TargetType="{x:Type ScrollViewer}" />
        <Style
            BasedOn="{StaticResource TelerikStyle}"
            TargetType="{x:Type TextBox}" />
        <Style
            BasedOn="{StaticResource TelerikStyle}"
            TargetType="{x:Type ToolTip}" />
    </Window.Resources>

and also this line inside of my window/user controllers constructor:

public MyWindow()
 {
            StyleManager.ApplicationTheme = new Windows8Theme();

            InitializeComponent()

 }

and it works.

Best Regards

kourosh

0
Martin Ivanov
Telerik team
answered on 19 Jun 2018, 11:57 AM
Hello Kourosh,

Thank you for sharing your solution.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GanttView
Asked by
Kourosh
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Kourosh
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or