Set style on programatically added buttons

7 posts, 0 answers
  1. Chad
    Chad avatar
    12 posts
    Member since:
    Apr 2008

    Posted 27 Oct 2010 Link to this post

    How can I set the style on buttons I add programatically?

    I have the toolbar defined like so:
    <toolbar:RadToolbarTray
    HorizontalAlignment="Left"
    x:Name="screenToolbar"
    VerticalAlignment="Top"
    telerikControls:StyleManager.Theme="Windows7" /> Then I add buttons like this:
    var button = new Button();
    
    tbar.Items.Add(button); //tbar is a toolbar object
    
    The buttons don't pick up the style of the tray... on the 
    silverlight side, I explicitly set the style of the button 
    before I add it to the toolbar (app resource), but I don't 
    see a way to pick up the toolbar button styles from the StyleManager...
    
    Thanks --
    
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 29 Oct 2010 Link to this post

    Hello Chad,

    I sent an answer to the support ticket you sent, but I will post it here as well:

    If a Telerik theme is applied to a RadToolBar, then all RadToolBar items (including newly added ones) should inherit this theme. However, if a theme is applied to the RadToolBarTray, it won't be applied to its content.

    I prepared a sample project illustrating this behavior. Can you please have a look at it and let me know if it works for you. Also, if I am missing something, please modify the sample to reproduce your issue and I will gladly investigate it further.

    Greetings,
    Tina Stancheva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Rayne
    Rayne avatar
    241 posts
    Member since:
    Sep 2010

    Posted 30 Nov 2010 Link to this post

    If I create a userControl with buttons on it and I want to add that userControl to the toolbar, how do I get it to pick up the styles of the toolbar?
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 03 Dec 2010 Link to this post

    Hello Rayne,

    I posted an answer to your other thread here. Please have a look at it and let me know if you need more info.

    Kind regards,
    Tina Stancheva
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  6. Rayne
    Rayne avatar
    241 posts
    Member since:
    Sep 2010

    Posted 03 Dec 2010 Link to this post

    Thank you.
  7. Allen
    Allen avatar
    50 posts
    Member since:
    Mar 2011

    Posted 19 May 2011 Link to this post

    Is it not also true that the new button must be a RadButton or it will have to be explicitly styled if generic?
  8. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 25 May 2011 Link to this post

    Hi Allen,

    The RadToolBar has predefined styles for both RadButton and Button (System.Windows.Controls.Button). So you don't need explicit style if you use Button. Please let us know if this is what you are actually asking. Hoe it helped you.

    Greetings,
    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready