Build RadToolBar based on data object.

4 posts, 0 answers
  1. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 16 Apr 2009 Link to this post

    Hi,

    I have a custom data object called MenuOption which looks like this:

    public class MenuOption

     

    {

     

     

       public string Caption { get; set; }

     

     

       public string ImagePath { get; set; }

     

     

     

       public ObservableCollection<MenuOption> Items { get; set; }

     

     

     

    }


    I would like to build a RadToolBar by binding this object to the ItemsSource property and using templates.

    <TNC:RadToolBarTray>

     

     

       <TNC:RadToolBar x:Name="mnuResult" ItemsSource="{Binding Path=ToolbarMenu.Items}/>

     

     

    </TelerikNavigationControls:RadToolBarTray>


    I thought at first that using a converter might be the proper solution and tried recursively iterating thruogh the items and building the controls as needed.  Then I ran into problems attaching events to the controls.  I have tried some other things without success either.
    Should I be looking at the ItemTemplateSelector to accomplish this since each individual MenuOption would possibly be a different control (Button, CheckBox, etc...)?

     

  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 20 Apr 2009 Link to this post

    Hi Rob,

    What problems you are facing when trying to attach an event handler to the dynamically created controls?

    Can't you use a single handler for all the buttons and switch the action based on the sender item?

    Greetings,
    Valentin.Stoychev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 20 Apr 2009 Link to this post

    Hi Valentin,

     

    I have added a post to the silverlight forums from Microsoft that better explains my problem.  It's not that I was unable to attach events to the the RadMenuItem, it's that I needed to include a RadMenuItem inside the item to attach the events to (if that makes sense)...

     

    http://silverlight.net/forums/t/90325.aspx

    Thanks for your help,
    Rob

  5. Bobi
    Admin
    Bobi avatar
    513 posts

    Posted 22 Apr 2009 Link to this post

    Hello Rob,

    Please refer to the following post:

    http://www.telerik.com/community/forums/silverlight/menu/binding-radmenuitem-icon-and-radmenuitem-header-properties-to-element-in-a-hierarchical-data-structure.aspx

    Here you can find a discussion and the solution of your problem. Let me know if this helps.

    Best wishes,
    Boryana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top