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

Programmatic HeaderTemplateSelector in RadPane not working

11 Answers 129 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 18 Oct 2011, 09:19 AM
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

11 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 21 Oct 2011, 08:53 AM
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 >>

0
Sascha
Top achievements
Rank 1
answered on 06 Feb 2012, 04:26 PM
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


0
Marc
Top achievements
Rank 1
answered on 08 Feb 2012, 03:11 PM
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
0
Tina Stancheva
Telerik team
answered on 15 Feb 2012, 03:18 PM
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 >>
0
Sascha
Top achievements
Rank 1
answered on 15 Feb 2012, 04:53 PM
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
0
Marc
Top achievements
Rank 1
answered on 15 Feb 2012, 06:02 PM
@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???
0
Sascha
Top achievements
Rank 1
answered on 16 Feb 2012, 09:40 AM
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
0
Brian Sayatovic
Top achievements
Rank 1
answered on 22 Aug 2014, 07:05 PM
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?
0
Kalin
Telerik team
answered on 26 Aug 2014, 11:00 AM
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.
 
0
Brian Sayatovic
Top achievements
Rank 1
answered on 26 Aug 2014, 12:46 PM
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.
0
Kalin
Telerik team
answered on 27 Aug 2014, 08:12 AM
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.
 
Tags
Docking
Asked by
Marc
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Sascha
Top achievements
Rank 1
Marc
Top achievements
Rank 1
Tina Stancheva
Telerik team
Brian Sayatovic
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or