UserControl styling in RadToolBar

2 posts, 0 answers
  1. Jon
    Jon avatar
    1 posts
    Member since:
    Aug 2010

    Posted 07 Sep 2011 Link to this post

    When I place a custom UserControl (which contains a TextBox and a RadButton) in a RadToolBar, how can I get the controls inside my UserControl to take on the re-styling that normally occurs when placing those controls directly into a toolbar?  I found this forum post:

    which provides an great example of how to apply a custom style for a custom control in a RadToolBar, but that's not what I'm looking for. How can I get the RadToolBar to re-style the individual elements of my custom control?
  2. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 08 Sep 2011 Link to this post

    Hi Jon,

    The RadToolBar controls has a predefined ItemContainerStyleSelector that sets default styles to the following types of elements:RadToolBarSeparator, TextBlock, TextBox, Button, ToggleButton, CheckBox, RadioButton, RadButton, RadToggleButton, RadRadioButton, RadDropDownButton, RadSplitButton.

    However, the ItemContainerStyleSelector can only be applied to direct children of the listed types and since in your case, the TextBox and RadButton are wrapped in another control before added to the RadToolBar you'll need to define a custom style for them. I attached a sample project that contains the predefined styles for the RadToolBar and its children. I also added a custom control with a TextBox and RadButton and I copied the RadToolBar TextBox and RadButton predefined styles and I applied it to the controls in the CustomControl. Please have a look at the solution and let me know if it helps.

    Best wishes,
    Tina Stancheva
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top