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

How do I use the HeaderTemplateSelector with the GroupBox

5 Answers 172 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Alexandre
Top achievements
Rank 1
Alexandre asked on 19 Jun 2013, 02:34 PM
Hi,

I would like to know how to use the HeaderTemplateSelector of the GroupBox control?

I would like to display a different header content in function of a boolean property in my view model. If true the header is a hyperlink button, else the header is a textblock.

I've read the following link: http://www.telerik.com/help/silverlight/radtabcontrol-templating-custom-header-template.html but this seems to be related to controls with items. In my case, I don't know to which property I should bind my boolean.

I know that there is others ways of doing what I want but I would like to learn how to use the TemplateSelector.

Thanks,

Alex

5 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 24 Jun 2013, 12:56 PM
Hi Alex,

Our RadTabControl derives from the native ItemsControl and this is why it exposes ItemTemplateSelector and ContentTemplateSelector properties. As far as I understand your requirement you want to use ItemTemplateSelector in your application.

In order to do so, you can create a custom class deriving from the native DataTemplateSelector. Furthermore you can override the SelectTemplate() method. In it you can implement your custom logic for switching the templates. Please note that you will have to define public properties that will be associated with the desired DataTemplates in XAML.

After creating your custom class, you can define your DataTemplates that will be applied based on your custom logic. This can be done in XAML. Next, you can create an instance of the custom ItemTemplateSelector and associate its properties (previously defined) with the DataTemplates that you have just defined.

Finally you can set the ItemTemplateSelector property of the RadTabControl.

For your convenience I implemented this approach in the attached project. Please take a look at it and let me know if you need any further assistance. If you need more explanations about the usage of the selectors you can refer to this blog post.

Regards,
Pavel R. Pavlov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Alexandre
Top achievements
Rank 1
answered on 25 Jun 2013, 01:47 PM
Hi,

Thanks for the answer but it's not really what I'm looking for. 

I'm working with the GroupBox control, not the RadTabControl and I want to use the HeaderTemplateSelector property of the GroupBox. The selected template would be based on boolean in the view model. If true, display a template else, display another template.

I understand the concept of deriving the DataTemplateSelector class and overriding the SelectTemplate() method but I don't know which property to bind so that the HeaderTemplateSelector (SelectTemplate method) is called.

With the RadTabControl, the selected template depends on the item of ItemsSources property but on which property depends the HeaderTemplateSelector property of the GroupBox control.

Thanks

Alex
0
Pavel R. Pavlov
Telerik team
answered on 28 Jun 2013, 10:40 AM
Hi Alex,

Please accept my apology for misleading you in my previous post. I assumed that you were using the RadTabControl because this forum targets our Silverlight controls only. Please post your question in our WinForms forum so that it can be properly handled.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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 >>
0
Alexandre
Top achievements
Rank 1
answered on 28 Jun 2013, 12:59 PM
Hi Pavel,

I'm doing a Silverlight application. I'm using the Telerik group box control.
<telerik:GroupBox Style="{Binding Source={StaticResource BaseGroupBox}}" Margin="10" Header="GroupBox">
  <StackPanel Orientation="Vertical">
    <TextBlock Text="{Binding oInformationPersonnel.oAdressePostale.sAdresse}" />
    <TextBlock Text="{Binding oInformationPersonnel.oAdressePostale.sVille}" />
  </StackPanel>
</telerik:GroupBox>

For some reason it's not listed in the following page: http://www.telerik.com/help/silverlight/introduction.html

Maybe it's not fully supported in Silverlight?
0
Pavel R. Pavlov
Telerik team
answered on 03 Jul 2013, 08:37 AM
Hi Alexandre,

The RadControls suite for Silverlight does not include such control, hence I can't be sure about your implementation. Can you please send us a runnable project to see how you try to use our controls. This will help us understand your scenario. You can log into your Telerik account and submit a support ticket with attached solution (as a zip).

Thank you for your cooperation.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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 >>
Tags
General Discussions
Asked by
Alexandre
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Alexandre
Top achievements
Rank 1
Share this question
or