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

Implicit Style and inheritance

6 Answers 311 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Geoffrey
Top achievements
Rank 1
Geoffrey asked on 29 Sep 2014, 09:30 AM
Hello,

I have some problems with controls which inherit from Telerik Control like RadOutlookBarItem, RadRibbonTab...

When I try to switch the style at runtime (merging of xaml dictionaries), the style is not changed.

When there are no inheritance, it works great.

How can I solve that ?

Thanks in advance.

Geoffrey

6 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 02 Oct 2014, 09:00 AM
Hello Geoffrey,

I'm not sure whether you have a custom control class library where you inherit from RadOutlookBarItem /RadRibbontab or you have a custom style in your project where you have customized our default control style. For the first case - since you have predefined the default control template in your Generic.xaml - you are losing the theming which is expected i.e. he new template will be applied to all themes. Please see attachment (the predefined Red Background will be applied to the RadOutlookBarItem no matter of the theme). 

In case you have custom style and you switch themes runtime - please make sure that this style gets added to your application's merged dictionaries everytime you are switching the theme. You might check our documentation article where this is explained (here's a link to it).

Regards,
Evgenia
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Geoffrey
Top achievements
Rank 1
answered on 02 Oct 2014, 09:09 AM
Hello Evgenia,

I have a classe RadOutlookBarSection which inherit from RadOutlookBarItem like that :

public class RadOutlookBarSection : RadOutlookBarItem
{
    public String TargetType { get; set; }
}

They are no style (no xaml.cs nor generic.xaml), I just add a property "TargetType" and I want the telerik style.

When I merge the telerik themes dictionaries at runtime. The RadOutlookBar is well themed, but the RadOutlookBarSection are not.

I hope that my problem is more understanding for you.

Best Regards,
Geoffrey

0
Evgenia
Telerik team
answered on 07 Oct 2014, 08:28 AM
Hi Geoffrey,

I prepared a sample project to reproduce the scenario you have, however everything is working as expected on my side. You might see the attachment below. Try to change themes by clicking on the buttons and you'll see that the Custom Outlook Bar Item theme gets correctly applied.
Could you please send us more details so that we can further assist you? How did you style the custom outlook bar item? What is the code (both xaml and code-behind) of your OutlookBar cotnrol?

Regards,
Evgenia
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Geoffrey
Top achievements
Rank 1
answered on 07 Oct 2014, 08:38 AM
Thanks for your answer.

Please change the MainWindow.xaml content to :

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="70" />
            <RowDefinition />
        </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal" >
                <Button Content="Office_Black" Click="Button_Click" Width="100" Margin="0 0 10 0"/>
                <Button Content="Office_Blue" Click="Button_Click" Width="100" Margin="0 0 10 0"/>
                <Button Content="Office_Silver" Click="Button_Click" Width="100" Margin="0 0 10 0"/>
                <Button Content="Summer" Click="Button_Click" Width="100" Margin="0 0 10 0"/>
                <Button Content="Transparent" Click="Button_Click" Width="100" Margin="0 0 10 0"/>
                <Button Content="Vista" Click="Button_Click" Width="100" Margin="0 0 10 0"/>
                <Button Content="Windows7" Click="Button_Click" Width="100" Margin="0 0 10 0"/>
                <Button Content="Expression_Dark" Click="Button_Click" Width="100" Margin="0 0 10 0"/>
                <Button Content="Windows8" Click="Button_Click" Width="100" Margin="0 0 10 0"/>
                <Button Content="Windows8Touch" Click="Button_Click" Width="100" Margin="0 0 10 0"/>
                <Button Content="Office2013" Click="Button_Click" Width="100" Margin="0 0 10 0"/>
                <Button Content="Office2013LightGray"  Click="Button_Click" Margin="0 0 10 0" Padding="10 0"/>
                <Button Content="Office2013DarkGray" Click="Button_Click" Margin="0 0 10 0" Padding="10 0"/>
                <Button Content="VisualStudio2013" Click="Button_Click" Margin="0 0 10 0" Padding="10 0"/>
                <Button Content="VisualStudio2013Dark"  Click="Button_Click" Margin="0 0 10 0" Padding="10 0"/>
                <Button Content="VisualStudio2013Blue" Click="Button_Click" Margin="0 0 10 0" Padding="10 0"/>
            </StackPanel>

            <telerik:RadOutlookBar Grid.Row="1">
                <local:MyCustomOutlookBarItem Header="Custom Outllok Item" Content="Test"/>
                <telerik:RadOutlookBarItem Header="Default Outlook Item" Content="Test"/>
            </telerik:RadOutlookBar>
    </Grid>

You will see that the custom item has always the same style.

Best regards,
Geoffrey Tincani
0
Evgenia
Telerik team
answered on 10 Oct 2014, 07:47 AM
Hi Geoffrey,

I reviewed again what we have written in this thread and I think I understand your scenario better now. At first when you run the application it applies the implicit styles that come from App.xaml -- both custom Outlookbar item (the one that inherits ours) and the default Outlookbar Item will be visible.
However when you change the theme by clicking on the buttons you are merging all files again but you are not seeing the custom item. In fact you need to merge a style with TargetType local:MyCustomOutlookBarItem BasedOn our default implicit style every time so that it gets applied. I modified the project I previously sent you, I believe it will explain better what I ment.

Regards,
Evgenia
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Geoffrey
Top achievements
Rank 1
answered on 16 Oct 2014, 07:47 AM
Thanks for your answer, it works well now.

Best regards,
Geoffrey
Tags
General Discussions
Asked by
Geoffrey
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Geoffrey
Top achievements
Rank 1
Share this question
or