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

DefaultStyleKey override

4 Answers 276 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 20 Mar 2009, 03:40 PM
Hello,

I am deriving from your RadNumericUpDown control and would like to override the DefaultStyleKey property and set my own style. Whenever I do this, I do not get any type of display no matter which properties I set in the new style. My guess is that there is no implementation for the BasedOn attribute for this control, so when I override the DefaultStyleKey I would need to create a new control template. Is there a chance that this feature could be implemented in the future? Or is there another way I could override the DefaultStyleKey without losing the base control template? Any suggestions would be appreciated. Thanks!

4 Answers, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 24 Mar 2009, 05:20 PM
Hi Martin,

Sorry for the late response.
Can you collaborate more on what you want to achieve?
If you override DefaultStyleKey then you should create new Style. Here is a little sample that I've made. The inherited numeric is displayed even if my style do not use BasedOn.

<Window x:Class="WpfApplication15.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:WpfApplication15" 
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
    Title="Window1" Height="300" Width="300">  
    <Window.Resources> 
        <Style TargetType="local:MyNumeric">  
            <Setter Property="Width" Value="250" /> 
            <Setter Property="Height" Value="30" /> 
            <Setter Property="Maximum" Value="200" /> 
        </Style> 
    </Window.Resources> 
    <Grid> 
        <local:MyNumeric Value="100" /> 
    </Grid> 
</Window> 

and the code-behind:
using System.Windows;  
using Telerik.Windows.Controls;  
 
namespace WpfApplication15  
{  
    /// <summary>  
    /// Interaction logic for Window1.xaml  
    /// </summary>  
    public partial class Window1 : Window  
    {  
        public Window1()  
        {  
            InitializeComponent();  
        }  
    }  
 
    public class MyNumeric : RadNumericUpDown  
    {  
        static MyNumeric()  
        {  
            FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(MyNumeric),  
                new FrameworkPropertyMetadata(typeof(MyNumeric)));  
        }  
    }  

I've added references to Telerik.Windows.Controls, Telerik.Windows.Controls.Input  and Telerik.Windows.Data.

Let us know if you need some help.

Sincerely yours,
Kaloyan Manev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Martin
Top achievements
Rank 1
answered on 24 Mar 2009, 05:51 PM
Hi Kaloyan,

Thank you for the response and the example code. I copied and pasted exactly what you provided, and I am still not seeing anything other than an empty window. I tried this with both the original assemblies that we purchased, and also the hotfix assemblies. Here is the product version of the assemblies that I am referencing:

2008.3.1217.35

Is there a newer version that I need to upgrade to? Also, I am currently running Window Vista Enterprise SP1. Not sure if that would make a difference at all. Please let me know if you can think of anything else that might be causing this behavior. Thanks.
0
Accepted
Hristo
Telerik team
answered on 24 Mar 2009, 06:54 PM
Hi Martin,

There is a newer version that we have released (2009.1 312) our official Q1 release.
Can you download and try it?

Waiting for your response.

Best wishes,
Hristo
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Martin
Top achievements
Rank 1
answered on 25 Mar 2009, 02:57 PM
Hi Hristo,

That turned out to be the problem. I got the latest version of your assemblies and I am now able to see the control. Thanks!

Martin
Tags
NumericUpDown
Asked by
Martin
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Martin
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or