How do I use the HeaderTemplateSelector with the GroupBox

6 posts, 0 answers
  1. Alexandre
    Alexandre avatar
    8 posts
    Member since:
    Feb 2012

    Posted 19 Jun 2013 Link to this post

    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
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 24 Jun 2013 Link to this post

    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.

  3. DevCraft banner
  4. Alexandre
    Alexandre avatar
    8 posts
    Member since:
    Feb 2012

    Posted 25 Jun 2013 Link to this post

    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
  5. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 28 Jun 2013 Link to this post

    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 >>
  6. Alexandre
    Alexandre avatar
    8 posts
    Member since:
    Feb 2012

    Posted 28 Jun 2013 Link to this post

    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?
  7. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 03 Jul 2013 Link to this post

    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 >>
Back to Top
DevCraft banner