DefaultStyleKey override

5 posts, 1 answers
  1. Martin
    Martin avatar
    11 posts
    Member since:
    Jan 2009

    Posted 20 Mar 2009 Link to this post

    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!
  2. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 24 Mar 2009 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Martin
    Martin avatar
    11 posts
    Member since:
    Jan 2009

    Posted 24 Mar 2009 Link to this post

    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.
  5. Answer
    Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 24 Mar 2009 Link to this post

    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.
  6. Martin
    Martin avatar
    11 posts
    Member since:
    Jan 2009

    Posted 25 Mar 2009 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready