No ItemsSource on StackPanel

Ribbon for WPF Forum

Posted 14 years ago by Keith I
Version: 10.1.0523
Avatar
I'm setting up items in my Ribbon using MVVM techniques. I have worked around the fact that Tabs don't have an ItemsSource property and I have created Tabs and Groups in code. I then set the Groups ItemSource property to the items that I want to show in the group.

I have a PopupButton and I have bound it's ItemsSource collection to an ObservableCollection and I have a DataTemplate to "convert" the internal type to the appropriate ribbon control. This works fine.

So, the question is, how do I do the same thing for a StackPanel? In other words, how do I set the items in a StackPanel using binding?

One final question, do you have an estimate for when the Ribbon will have full MVVM support?

Thanks,
Keith

Comments (3)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Keith,

Right now StackPanel is a Panel, not an ItemsControl. So we can't directly set up databinding on it.

You may be able to use an attached property of type IEnumerable and when that property changes, add/remove from the Panel.Children property as needed. You'd probably also want to see if it implements INotifyCollectionChanged and if so, update the Children in a CollectionChanged event handler.

Our top priority for the next 2010.2 version is to add Office 2010 styles to Ribbon, then we'll want to add backstage support. MVVM is something we'd like to get into as well for it however it may require some breaking changes so that would likely happen in a post 2010.2 version.


Actipro Software Support

Posted 14 years ago by Keith I
Avatar
Thank you for the reply.

I've managed to implement it using the following DataTemplate:

  <DataTemplate DataType="{x:Type local:MyStackPanelData}">
    <ribbon:StackPanel>
      <ItemsControl ItemsSource="{Binding Items}"/>
    </ribbon:StackPanel>
  </DataTemplate>
...and class MyStackPanelData contains an ObservableCollection called Items.
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Keith,

The only note with that setup is that variants may not work.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.