This is a migrated thread and some comments may be shown as answers.

Build RadToolBar based on data object.

3 Answers 79 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 16 Apr 2009, 02:55 PM
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...)?

 

3 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 20 Apr 2009, 09:35 AM
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.
0
Rob
Top achievements
Rank 1
answered on 20 Apr 2009, 01:41 PM

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

0
Bobi
Telerik team
answered on 22 Apr 2009, 01:29 PM
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.
Tags
ToolBar
Asked by
Rob
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Rob
Top achievements
Rank 1
Bobi
Telerik team
Share this question
or