Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > ToolBar > Set style on programatically added buttons

Not answered Set style on programatically added buttons

Feed from this thread
  • Chad avatar

    Posted on Oct 27, 2010 (permalink)

    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 --
    

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Oct 29, 2010 (permalink)

    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
    Attached files

    Reply

  • Posted on Nov 30, 2010 (permalink)

    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?

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Dec 3, 2010 (permalink)

    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

    Reply

  • Posted on Dec 3, 2010 (permalink)

    Thank you.

    Reply

  • Allen avatar

    Posted on May 19, 2011 (permalink)

    Is it not also true that the new button must be a RadButton or it will have to be explicitly styled if generic?

    Reply

  • Petar Mladenov Petar Mladenov admin's avatar

    Posted on May 25, 2011 (permalink)

    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

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > ToolBar > Set style on programatically added buttons
Related resources for "Set style on programatically added buttons"

WPF ToolBar Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]