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

How to bind custom ObservableCollection to RadRibbonSplitButton

2 Answers 116 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
Travis
Top achievements
Rank 1
Travis asked on 15 Jun 2013, 08:36 PM
Hello,

I've got a custom ObservableCollection I want to bind to using RadRibbonSplitButton.

Is there a simple example how to bind a collection to a RadRibbonSplitButton (or RadSplitButton?) DropDown data context?

Thanks!

Regards,

Michael Powell

2 Answers, 1 is accepted

Sort by
0
Travis
Top achievements
Rank 1
answered on 15 Jun 2013, 11:09 PM
A little elaboration. Here is the binding I am trying to use. Probably it is amiss somewhat:

<telerik:RadRibbonGroup Header="Reports">
    <telerik:RadRibbonSplitButton Name="radsbGenerateReport" DataContext="ReportView" LargeImage="/ResultsViewer;component/Images/page_word.png" HorizontalAlignment="Left" ContextMenuOpening="radsbGenerateReport_ContextMenuOpening" DropDownOpening="radsbGenerateReport_DropDownOpening" Click="radsbGenerateReport_Click" Text="Generate Report" Size="Large" DropDownPlacement="Bottom">
        <telerik:RadRibbonSplitButton.DropDownContent>
            <ListBox DataContext="Value" x:Name="lbReportView">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Name}" />
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </telerik:RadRibbonSplitButton.DropDownContent>
    </telerik:RadRibbonSplitButton>
</telerik:RadRibbonGroup>

The model and view I am attempting to use is something like this:

class MyModel
{
  //For forum purposes.
  public string Name {get;set;}
  public MyModel(){}
}
 
public MyModelCollection : ObservableCollection<MyModel>
{
  //There's more there, but this is the fundamental collection.
  public MyModelCollection() : base(new List<MyModel>()) {}
}
 
//Actually implements INotifyPropertyChanged.
public MyModelCollectionView
{
  public MyModelCollection Value { get;set; }
 
  public MyModelCollectionView(MyModelCollection value)
  {
    Value = value;
  }
}

ReportView is an instance of MyModelCollectionView, or at least I think it should be.

I'd actually like there to be an "Add Report" command-pattrern-based entry. Then the rest of the items being the reports themselves.

When user clicks on a report in the drop down, report generates, and so on and so forth.
0
Travis
Top achievements
Rank 1
answered on 16 Jun 2013, 01:17 PM
Figured out a workable solution. Populated with a Xaml RadContextMenu and named the menu. Then I populate with known RadMenuItem instances.
Tags
Buttons
Asked by
Travis
Top achievements
Rank 1
Answers by
Travis
Top achievements
Rank 1
Share this question
or