ItemContainerStyle Causing Telerik radTreeview to disappear. (WPF)

5 posts, 0 answers
  1. Jawad
    Jawad avatar
    10 posts
    Member since:
    Jul 2013

    Posted 11 Jul 2013 Link to this post

    Hi,
    the application is based on MVVM using Prism with MEF.
    I have converted  windows tree view control to Telerik RadTreeview control. everything worked fine except that the ItemContainerStyle defined is somehow disabling the tree to be shown.  if I remove the ItemContainerStyle from the Radtreeview the tree becomes visible but with not styling.
     by using the windows treeview with same ItemcontainerStyle work fine.
    Following is the code.

    <uxc:UxtWindow.Resources>
     <HierarchicalDataTemplate x:Key="SiteWizardTemplate" 
                                      ItemsSource="{Binding Steps}" >
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding DisplayAs}" />
                </StackPanel>
            </HierarchicalDataTemplate>
        </uxc:UxtWindow.Resources>
      
     <telerik:RadTreeView  IsVirtualizing="True"
                             ItemsSource="{Binding Wizard.WizardSections}" 
                              ItemTemplate="{StaticResource SiteWizardTemplate}"                                          
                                   PreviewMouseDown="TreeView_PreviewMouseDown" >
                                
                                   <telerik:RadTreeView.ItemContainerStyle>
                                    <Style TargetType="{x:Type telerik:RadTreeViewItem}">
                                        <Setter Property="FontSize" Value="18" />
                                        <Setter Property="FontStyle" Value="Italic" />
                                        <Setter Property="Margin" Value="0,5,0,10" />
                                        <Setter Property="Foreground" Value="Black" />
                        </telerik:RadTreeView.ItemContainerStyle>
                          
                                
    </telerik:RadTreeView>
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 16 Jul 2013 Link to this post

    Hi Jawad,

    Unfortunately I was not able to reproduce this issue. However, I feel there might be something I'm missing from your implementation. Can you please have a look at the attached solution and let me know if it works for you. Also, if it doesn't properly describes your scenario, can you try to modify it to better demonstrate your case and reproduce the described issue. This will allow us to locally investigate it and suggest a solution.

    Thank you in advance for your cooperation on the mater.

    Regards,
    Tina Stancheva
    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
  4. Jawad
    Jawad avatar
    10 posts
    Member since:
    Jul 2013

    Posted 22 Jul 2013 Link to this post

    by adding BasedOn Property on the Style fixed the issue. 

    <Style x:Key="MainStepStyle" TargetType="{x:Type telerik:RadTreeViewItem}" BasedOn="{StaticResource RadTreeViewItemStyle}">
  5. Thomas
    Thomas avatar
    17 posts
    Member since:
    Oct 2012

    Posted 02 Feb 2014 Link to this post

    Just wanted to confirm that this also solved my issue, so thank you for posting this. Took me a while to figure this out.

    I believe this is only an issue when you are using implicit styles. In my case, when I switched the Telerik.Windows.Controls.Navigation assembly (which contains the RadTreeView) to the NoXaml version used for implicit styling, this issue came up. When I switched back to the all-including Xaml version, the issue disappeared. However, this is typically not what you want, if you have decided to use implicit styles. So we really need to get to the root of this issue.

    Here's my attempt at an explanation: In the documentation, including the BasedOn property is the approach explained. Using BasedOn is what you need to do in order to "override" a style that has already been defined by the Telerik team, and included in the Theme Xaml DLL you're using.

    In the case above, you want to modify the RadTreeViewItem style by just setting the properties you want to override. In order to do that, you must include the BasedOn property, otherwise you would have to include all properties of the RadTreeViewItem.

    In my case, I wanted to bind the IsExpanded property of each node in the tree to the matching property of my view model for the tree, and including the BasedOn property also did the trick here.



  6. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 05 Feb 2014 Link to this post

    Hi Thomas,

    Thanks for jumping in and shedding more light on the issue. Your explanation is absolutely correct and the only thing I want to add to it is a small piece of information regarding the NoXaml assemblies.

    As their name suggests, those are assemblies that do not contain any xaml - no style resources or ControlTemplates are applied on the components defined in these assemblies. This is why it is up to you to apply a style on a component referenced from a NoXaml assembly. You can do that by defining a custom style - which means that you will need to also define a ControlTemplate for the component, or by including our default styles. In the second case, if you need to change a few setters you would need to base your custom style on a default style in order to make sure that the default style setters are also applied, specifically so that they can set a ControlTemplate for the component.

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