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

binding buttons to ribbon groups

1 Answer 230 Views
RibbonView and RibbonWindow
This is a migrated thread and some comments may be shown as answers.
rocker
Top achievements
Rank 1
rocker asked on 04 Jul 2017, 08:41 AM

hi, 

I am trying to create a ribbon  menu from a json file. Tabs ands groups are being displayed. But buttons are not. instead, the class names of the buttons are displayed as text and they can not be clicked. what could be the reason ? any example of such system would be appreciated.

so here are my business objects:

01.public class RibbonTab {
02.    public string header { getset; }
03.    public List<RibbonGroup> ribbonGroups { getset; }
04.}
05.  public class RibbonGroup {
06.    public string header { getset; }
07.    public List<RibbonButton> ribbonButtons { getset; }
08.}
09.  public class RibbonButton {
10.  
11.    public string text { getset; }
12.    public string icon { getset; }
13.    public int size { getset; }
14.    public string parentPage { getset; }
15.  
16.    public string ButtonText { get return text; } }
17.    public Telerik.Windows.Controls.RibbonView.ButtonSize ButtonSize
18.    {
19.        get         {
20.            return (Telerik.Windows.Controls.RibbonView.ButtonSize)size;
21.        }
22.    }
23.}

 

here is my view:

<UserControl.Resources>        
<Style TargetType="{x:Type telerik:RadRibbonButton}">            
<Setter Property="Text" Value="{Binding ButtonText}" />        
</Style>        
<Style TargetType="telerik:RadRibbonGroup">            
<Setter Property="Header" Value="{Binding header}" />            
<Setter Property="ItemsSource" Value="{Binding ribbonButtons}" />        
</Style>        
<Style TargetType="telerik:RadRibbonTab">            
<Setter Property="Header" Value="{Binding header}" />            
<Setter Property="ItemsSource" Value="{Binding ribbonGroups}" />        
</Style>    
</UserControl.Resources>    

 

<telerik:RadRibbonView  ItemsSource="{Binding RibbonTabs}" />

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 06 Jul 2017, 08:18 AM
Hello Rocker,

This behavior is expected with every items control in the WPF framework. When you have a data binding scenario where you use the ItemsSource of the control you will also need to define an ItemTemplate. Otherwise, the control will generate its default container and populate it with the result returned from the ToString() method of the business object. 

You can see how to use RadRibbonView in an data binding scenario in the Paint with MVVM demo.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
RibbonView and RibbonWindow
Asked by
rocker
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or