I'm attempting to adapt the XamRibbon to run as a region in PRISM. It made the most sense for me to base the ribbon's adapter off of the tab or selector adapter as there's a concept of the currently selected tab.
I'm however, not finding any of the following that would faciilitate this:
* A SelectedTab property
* PropertyChanged on the tabs themselves.
* A SelectedTabChanged event at the ribbon level.
Can you help on how I can detect when the ribbon itself has had it's selected value changed (either to a regular or contextual tab?
Hello,Currently the XamRibbon does not expose such properties of evens. However, you could inherit the the XamRibbonTabItem and based on its IsSelected property change to keep track of the last selected tab. You can also inherin the XamRibbon and expose a SelectedTab property.
You might also want to submit these as features here and we will try to include them in future releases.
I've been able to implement this by tracking the IsSelected Dependency Property on XamRibbonTabItem
public void RegisterForNotification(string propertyName, FrameworkElement element, PropertyChangedCallback callback)
{
var binding = new Binding(propertyName) { Source = element };
var property = DependencyProperty.RegisterAttached(
"ListenAttached" + propertyName,
typeof(object),
typeof(UserControl),
new PropertyMetadata(callback));
element.SetBinding(property, binding);
}
Use it on all tabs. Like this.
foreach (var tab in xamWebRibbon1.Tabs)
RegisterForNotification("IsSelected", tab,
(d, e) =>
var tabItem = d as XamRibbonTabItem;
if(tabItem.IsSelected)
Debug.WriteLine(string.Format("IsSelected {0}", tabItem.Name));
});