Link a RibbonTab to its own Workspace
-
I'm trying to create a workspace for each RibbonTab of my app. But I'm struggling to workout the best method to do this. RibbonTabs are setup as:
<r:RibbonTab Label="Home" Behaviors:SingleEventCommand.RoutedEventName="Selected" Behaviors:SingleEventCommand.TheCommandToRun="{Binding Tab_HomeSelected}" >
<r:RibbonGroup Name="Documentation" Command="{StaticResource DocumentationGroupCommand}">
<r:RibbonButton Command="{StaticResource GeneralDocCommand}" />
<r:RibbonButton Command="{StaticResource FactsDocCommand}" />
</r:RibbonGroup>
</r:RibbonTab>
<r:RibbonTab Label="Config" Behaviors:SingleEventCommand.RoutedEventName="Selected" Behaviors:SingleEventCommand.TheCommandToRun="{Binding Tab_ConfigSelected}" >
<r:RibbonGroup Name="Documents" Command="{StaticResource DocumentGroupCommand}">
<r:RibbonButton Command="{StaticResource DocsCommand}" />
</r:RibbonGroup>
</r:RibbonTab>The workspaces/viewmodels are currently inside a Tabcontrol
<local:TabControlEx x:Name="tabControl"
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Path=Workspaces}"
Template="{StaticResource MainTabControlTemplateEx}">
</local:TabControlEx>public MainViewModel()
{
#region Workspaces
///Build workspace areas for each ribbon tab
Workspaces = new ObservableCollection<ViewModelBase>();
Workspaces.CollectionChanged += this.OnWorkspacesChanged;HomeViewModel vmH = new HomeViewModel(); vmH.IsCloseable = false; Workspaces.Add(vmH); ConfigViewModel vmCf = new ConfigViewModel(); vmCf.IsCloseable = false; Workspaces.Add(vmCf); tabH = new SimpleCommand { CanExecuteDelegate = x => true, ExecuteDelegate = x => ExecuteCommandHome() }; tabC = new SimpleCommand { CanExecuteDelegate = x => true, ExecuteDelegate = x => ExecuteCommandConfig() };
}
public ICommand Tab_HomeSelected { get {return tabH; } }
public ICommand Tab_ConfigSelected { get {return tabC; } }This method works currently when switching from one RibbonTab to another but the tabcontrol also shows the tab headings for each Ribbontab... not very nice. Does anybody have a better solution or suggestion as to how this could work? Many Thanks
-
I'm trying to create a workspace for each RibbonTab of my app. But I'm struggling to workout the best method to do this. RibbonTabs are setup as:
<r:RibbonTab Label="Home" Behaviors:SingleEventCommand.RoutedEventName="Selected" Behaviors:SingleEventCommand.TheCommandToRun="{Binding Tab_HomeSelected}" >
<r:RibbonGroup Name="Documentation" Command="{StaticResource DocumentationGroupCommand}">
<r:RibbonButton Command="{StaticResource GeneralDocCommand}" />
<r:RibbonButton Command="{StaticResource FactsDocCommand}" />
</r:RibbonGroup>
</r:RibbonTab>
<r:RibbonTab Label="Config" Behaviors:SingleEventCommand.RoutedEventName="Selected" Behaviors:SingleEventCommand.TheCommandToRun="{Binding Tab_ConfigSelected}" >
<r:RibbonGroup Name="Documents" Command="{StaticResource DocumentGroupCommand}">
<r:RibbonButton Command="{StaticResource DocsCommand}" />
</r:RibbonGroup>
</r:RibbonTab>The workspaces/viewmodels are currently inside a Tabcontrol
<local:TabControlEx x:Name="tabControl"
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Path=Workspaces}"
Template="{StaticResource MainTabControlTemplateEx}">
</local:TabControlEx>public MainViewModel()
{
#region Workspaces
///Build workspace areas for each ribbon tab
Workspaces = new ObservableCollection<ViewModelBase>();
Workspaces.CollectionChanged += this.OnWorkspacesChanged;HomeViewModel vmH = new HomeViewModel(); vmH.IsCloseable = false; Workspaces.Add(vmH); ConfigViewModel vmCf = new ConfigViewModel(); vmCf.IsCloseable = false; Workspaces.Add(vmCf); tabH = new SimpleCommand { CanExecuteDelegate = x => true, ExecuteDelegate = x => ExecuteCommandHome() }; tabC = new SimpleCommand { CanExecuteDelegate = x => true, ExecuteDelegate = x => ExecuteCommandConfig() };
}
public ICommand Tab_HomeSelected { get {return tabH; } }
public ICommand Tab_ConfigSelected { get {return tabC; } }This method works currently when switching from one RibbonTab to another but the tabcontrol also shows the tab headings for each Ribbontab... not very nice. Does anybody have a better solution or suggestion as to how this could work? Many Thanks
What is a RibbonTab ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.