This project is read-only.

InRibbonGallery PART_ListBox IsSynchronizedWithCurrentItem

Sep 8, 2010 at 10:13 PM

Hi,

can you set the "IsSynchronizedWithCurrentItem" on the "PART_ListBox" to true or expose it in another way, so that shown collections automatically update?

Greets

Sep 9, 2010 at 8:08 PM
Edited Sep 9, 2010 at 11:15 PM

In v1.3 it is not enough to set IsSynchronizedWithCurrentItem to true. In the current version it doesn't show the items from an ObservableCollection<T>.

The InRibbonGallery is populated with an ItemsSource="{Binding Path=ObservableCollection<T>}" from a viewmodel and an ItemTemplate="{StaticResource CoolTemplate}", which is defined in the UserControl.Resources where the Ribbon is hosted.

Whith the following template i can achieve that selecting listbox items changes the active item in the ObservableCollection<T> back from the view model.

<ContentControl Content="{Binding Path=ObservableCollection<T>}"
                         ContentTemplate="{StaticResource GalleryTemplate}"
                         />

<HierarchicalDataTemplate x:Key="GalleryTemplate">
  <ListBox ItemsSource="{Binding}"
           ItemTemplate="{StaticResource CoolTemplate}"
           IsSynchronizedWithCurrentItem="True"
           >
    <ItemsControl.ItemsPanel>
      <ItemsPanelTemplate>
        <WrapPanel />
      </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
  </ListBox>
</HierarchicalDataTemplate>