RadTreeListView inheritance.

2 posts, 0 answers
  1. Anton
    Anton avatar
    12 posts
    Member since:
    Sep 2012

    Posted 09 Oct 2013 Link to this post

    I've tried to inherit class from RadTreeListView and add it on form via XAML and app shows nothing in debug.
    How can I fix it quickly?
    RadControls version = 2011.3.1220.40

    public class TestTreeView : RadTreeListView
    {
    }
    <controls:TestTreeView ItemsSource="{Binding Items}" />  -> empty screen
    ...
    <t:RadTreeListView ItemsSource="{Binding Items}" />  -> fine
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 11 Oct 2013 Link to this post

    Hello,

    If you are setting the theme to your custom grid using StyleManager you have to set the DefaultStyleKey in the OnInitialized method. In general we are using composite key to set the theme to per control.
    The snippet below demonstrates how to set any Telerik theme to a custom control named TestTreeView, which inherits RadTreeListView: 

    public class TestTreeView:RadTreeListView
    {
        static TestTreeView()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(MyCustomGrid), new FrameworkPropertyMetadata(typeof(MyCustomGrid)));
        }
     
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            Theme theme = StyleManager.GetTheme(this);
            Type themeType = null;
            if (theme != null)
            {
                themeType = theme.GetType();
            }
            this.DefaultStyleKey = new ThemeResourceKey() { ElementType = typeof(RadTreeListView), ThemeType = themeType };
        }
    }


    You can also check this forum thread.

    I hope this helps.


    Regards,
    Didie
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top