Hi,
I create a DependencyProperty for my WPF RibbonTab:
public static class ExecuteViewParameter
{
// Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ExecuteViewParametersProperty =
DependencyProperty.RegisterAttached("ExecuteViewParameters", typeof(ExecuteViewType), typeof(ExecuteViewParameter), new PropertyMetadata(ExecuteViewType.Hebrew));
public static void SetExecuteViewParameters(DependencyObject element, ExecuteViewType value)
{
element.SetValue(ExecuteViewParametersProperty, value);
}
public static ExecuteViewType GetExecuteViewParameters(DependencyObject element)
{
return (ExecuteViewType)element.GetValue(ExecuteViewParametersProperty);
}
}
XAML:
<RibbonTab Header="Greek Table" infDependencyObjects:ExecuteViewParameter.ExecuteViewParameters="{Binding Source={x:Static infModels:ExecuteViewType.GreekTable}}" ContextualTabGroupHeader="Table Workspace" Style="{StaticResource TableGreekContextualTabVisibility}"><RibbonGroup Name="UpdateGreekTable" Header="Greek Table"><RibbonButton
Label="Update"
SmallImageSource="/Natsar.Common;component/Resources/Green.png" LargeImageSource="/Natsar.Common;component/Resources/GreenLarge.png"
IsEnabled="{Binding Path=PropertiesService.IsEnabledUpdateGreekTableCommand, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
infDependencyObjects:ViewNamesParameter.ViewParameters="{Binding Source={x:Static inf:ViewNames.GreekTableView}}"
infDependencyObjects:ActiveViewNamesParameter.ActiveViewParameters="{Binding Source={x:Static inf:ActiveViewNames.WritingsTableManagerView}}"
infDependencyObjects:ExecuteViewParameter.ExecuteViewParameters="{Binding Source={x:Static infModels:ExecuteViewType.GreekTable}}"
Style="{StaticResource UpdateTableCommand}"/><RibbonButton
Label="Create"
SmallImageSource="/Natsar.Common;component/Resources/Yellow.png"
IsEnabled="{Binding Path=PropertiesService.IsEnabledCreateGreekTableContentCommand, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
infDependencyObjects:ViewNamesParameter.ViewParameters="{Binding Source={x:Static inf:ViewNames.GreekTableView}}"
infDependencyObjects:ActiveViewNamesParameter.ActiveViewParameters="{Binding Source={x:Static inf:ActiveViewNames.WritingsTableManagerView}}"
infDependencyObjects:ExecuteViewParameter.ExecuteViewParameters="{Binding Source={x:Static infModels:ExecuteViewType.GreekTable}}"
Style="{StaticResource CreateTableCommand}"/></RibbonGroup></RibbonTab>In my code I'm capturing the SelectionChanged event:
public void OnRibbonSelectionChangedEvent(object sender, SelectionChangedEventArgs args)
{
try
{
RibbonTab tab = (sender as Ribbon).SelectedItem as RibbonTab;
if (tab is RibbonTab && tab != null)
{
this.eventAggregator.GetEvent<MessageUpdateEvent>().Publish(new MessageUpdateEvent { Message = "You selected " + tab.ToString() });
}
}
catch (Exception msg)
{
.....
}
}How do I get the DependencyProperty value?
Thanks!...
Code is like a box of chocolates!...