Programmatic HeaderTemplateSelector in RadPane not working

12 posts, 0 answers
  1. Marc
    Marc avatar
    88 posts
    Member since:
    Jul 2011

    Posted 18 Oct 2011 Link to this post

    Is there any reason why my selector is never called when I do the following:

    RadPane pane = new RadPane();
    pane.HeaderTemplateSelector = new HeaderTemplateSelector();

    Setting a breakpoint in "SelectTemplate" shows, that it is never called and consequently the tab (header) is eventually empty. I get the same issues when programmatically setting the HeaderTemplate property instead of the HeaderTemplateSelector.


    Is this a known bug or am I doing something wrong?

    Regrads,
    Stephan

  2. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 21 Oct 2011 Link to this post

    Hi Stephan,

    Thank you for reporting us this issue - I logged in PITS where you can track its progress. Your Telerik points were updated for your cooperation.

    Regards,
    Miroslav Nedyalkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Sascha
    Sascha avatar
    15 posts
    Member since:
    Aug 2010

    Posted 06 Feb 2012 Link to this post

    Hello,

    the Entry in PITS is in the wrong catory and is canceled, but the bug still exists in Silverlight RadControls for Silverlight, v.2011.3.1205.1040.

    Any news regarding this bug?


    Regards,
    Sascha


  5. Marc
    Marc avatar
    88 posts
    Member since:
    Jul 2011

    Posted 08 Feb 2012 Link to this post

    I'm also still interested in this issue. When will this be fixed? Any news?

    Just tried again to set the pane's Header to my viewmodel and the pane's HeaderTemplateSelector to my DataTemplateSelector implementation. No success! :-(


    Thank you,
    Stephan
  6. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 15 Feb 2012 Link to this post

    Hi guys,

    The item in PITS is cancelled since the issue is related to the RadTabItem from which the RadPane control derives.

    Basically in Silverlight the only way to apply a HeaderTemplateSelector property to a RadTabItem is to bind the ItemsSource of the RadTabControl and set the ItemContainerStyle property to apply a style setter setting the HeaderTemplateSelector property to the RadTabItems containers.

    In Silverlight you can't manually apply a HeaderTemplateSelector property to a RadTabItem by setting the RadTabItem.HeaderTemplateSelector property because the ContentPresenter used to represent the header content of the items doesn't support such a property and this is why the property value cannot be directly propagated. But as this is an expected behavior and not a supported scenario in the RadTabControl, we won't be looking for fixes at the moment.

    Please accept our apology for this inconvenience.

    Greetings,
    Tina Stancheva
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  7. Sascha
    Sascha avatar
    15 posts
    Member since:
    Aug 2010

    Posted 15 Feb 2012 Link to this post

    OK,

    so I tried this one:


    <telerik:RadPane x:Name="paneFilterMenu"
    	Width="Auto"
    	HorizontalContentAlignment="Stretch"
    	VerticalContentAlignment="Stretch"
    	AllowDrop="True"
    	CanDockInDocumentHost="false"
    	CanFloat="False"
    	CanUserClose="False"
    	CanUserPin="True"
    	Header="{Binding DataContext.SelectedItem.Content.ViewContent.DataContext,
    		ElementName=LayoutRoot}"
    		HeaderTemplate="{StaticResource CISHeaderTemplateMenu}"
    		IsPinned="{Binding DataContext.IsMenuPanePinned,
    			ElementName=LayoutRoot,
    			Mode=TwoWay}">
    
    The HeaderTemplate shows from the ViewContent.DataContext a Picture and a caption.
    This works fine, if the pane is unpinned, on the left I can see the picture and the caption.
    
    But, if the pane is pinned, the headertemplate is ignored and only the objectname of the ViewContext.DataContext is displayed.
    
    I've attached two images of this behavior.
    
    So, how to correct this one?
    
    Regards,
    Sascha
  8. Marc
    Marc avatar
    88 posts
    Member since:
    Jul 2011

    Posted 15 Feb 2012 Link to this post

    @Tina: Well, thanks for your answer. Not what I wanted to hear but ok ... :-)

    @Sacha: I haven't had a detailed look at your xaml but looking at your images I think you mix up RadPane's Header and Title property. The header of a RadPane is used as tab content whenever there are is more than one pane in a pane group or e.g. when the pane is unpinned (RightDisplay.png). The title of a RadPane is shown in the RadPaneGroup's "titlebar" whenever the pane is active in that group (WrongDisplay.png). As far as I remember the Title property is always rendered as string (look at the sources) even though you set it to a UIElement. So there might be no chance to display an icon here.

    I just had a look at the sources of RadPane:

    private static void OnTitlePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)
    {
        if (args.NewValue is UIElement)
        {
            d.SetValue(RadPane.TitleProperty, args.NewValue.ToString());
        }
    }


    @Tina: Is there any reason why the title is restricted to string???
  9. Sascha
    Sascha avatar
    15 posts
    Member since:
    Aug 2010

    Posted 16 Feb 2012 Link to this post

    Hello Stephan,

    thanks for your hint. I've only used the Header Property, the Title was never set. And without Headertemplate and the Header bound to a string you never see a difference between the title and the header.

    But now, I've bound the Header to an object with two properties (Image and Caption) and assigned the header Template.
    In this case, the Header works, but the Title not.

    I've assigned the "CISHeaderTemplateMenu" to the TitleTemplate Property, now the TitleBar is correct.

    Thanks,

    Sascha
  10. Brian Sayatovic
    Brian Sayatovic avatar
    91 posts
    Member since:
    Nov 2009

    Posted 22 Aug 2014 in reply to Marc Link to this post

    I've just stumbled into this same thing.  It looks like any time the 'Title' dependency property of a RadPane is set, it's own property change callback replaces itself with the .ToString() value of the object set as the title.  Why declare the dependency property as being of type 'object' and then subversively set to a string?
  11. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 26 Aug 2014 Link to this post

    Hello Brian,

    When binding the Title to a custom object you would need to also define a TitleTemplate as well as a HeaderTemplate in order to successfully. If those templates are not defined the ToSting() method of the bound object will be called.

    Hope this helps.

    Regards,
    Kalin
    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.
     
  12. Brian Sayatovic
    Brian Sayatovic avatar
    91 posts
    Member since:
    Nov 2009

    Posted 26 Aug 2014 Link to this post

    Yes, but there still seems to be a problem.  RadPane.TitleProperty is a dependency property defined as typeof(object), but the PropertyMetadata registers a property change handler, RadPane.OnTitlePropertyChanged, that seems to set the value to "value.ToString()".  So it seems that even when I set an object, even a rich, custom object, it still seems to get turned into a string.
  13. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 27 Aug 2014 Link to this post

    Hi Brian,

    The property is set to the NewValue.ToString() only whenever an UIElement is set as Title of the Pane. If you assign a regular data object - the property will be set as expected (it won't be set to NewValue.ToString()). However if you need to display correctly the properties of the custom object you would also need to define a DataTemplate and assign it as TitleTemplate of the Pane.




    Hope this helps.

    Regards,
    Kalin
    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.
     
Back to Top
DevCraft banner