How to bind custom ObservableCollection to RadRibbonSplitButton

3 posts, 0 answers
  1. Travis
    Travis avatar
    49 posts
    Member since:
    Dec 2012

    Posted 15 Jun 2013 Link to this post

    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. Travis
    Travis avatar
    49 posts
    Member since:
    Dec 2012

    Posted 15 Jun 2013 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Travis
    Travis avatar
    49 posts
    Member since:
    Dec 2012

    Posted 16 Jun 2013 Link to this post

    Figured out a workable solution. Populated with a Xaml RadContextMenu and named the menu. Then I populate with known RadMenuItem instances.
Back to Top