BackStage closing

Ribbon for WPF Forum

Posted 10 years ago by Konstantin - Edifecs
Version: 13.1.0581
Platform: .NET 4.0
Environment: Windows 7 (64-bit)
Avatar

Hi, here is simple example to reproduce issue:

<ribbon:RibbonWindow x:Class="TestBackStage.Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
xmlns:themes="http://schemas.actiprosoftware.com/winfx/xaml/themes"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
RenderOptions.ClearTypeHint="Enabled"
ShowInTaskbar="True"
MinHeight="480"
MinWidth="640" 
d:DesignHeight="480"
d:DesignWidth="640"
AllowsTransparency="False"
themes:ThemeProperties.IsTransparencyModeEnabled="False">
<ribbon:RibbonWindow.Resources>
		<Style TargetType="{x:Type TextBlock}" x:Key="ReadOnlyValueStyle">
			<Setter Property="Margin" Value="12,0,0,0"/>
			<Setter Property="Foreground" Value="Gray"/>
			<Setter Property="Height" Value="22"/>
			<Setter Property="Width" Value="150"/>
			<Setter Property="VerticalAlignment" Value="Center"/>
			<Setter Property="FontSize" Value="12"/>
			<Setter Property="SnapsToDevicePixels" Value="True"/>
			<Setter Property="HorizontalAlignment" Value="Left"/>
		</Style>

		<Style TargetType="{x:Type TextBlock}" x:Key="NameStyle">
			<Setter Property="Foreground" Value="Black"/>
			<Setter Property="Height" Value="22"/>
			<Setter Property="FontSize" Value="12"/>
			<Setter Property="SnapsToDevicePixels" Value="True"/>
		</Style>
	</ribbon:RibbonWindow.Resources>
	<DockPanel>
		<!-- Ribbon Control -->
		<ribbon:Ribbon x:Name="_ribbon" DockPanel.Dock="Top" >
			<ribbon:Ribbon.ApplicationMenu>
				<!-- Backstage (Could alternatively use ApplicationMenu control) -->
				<ribbon:Backstage x:Name="appMenu">
					<ribbon:BackstageTab Name="Info" Header="Info" KeyTipAccessText="I">
						<DockPanel Margin="18,0,0,0">
							<ribbon:Separator DockPanel.Dock="Top" Label="Document Properties" Context="BackstageItem"/>

							<Grid Grid.Row="1" Margin="10,10,0,0">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="Auto"/>
									<ColumnDefinition Width="*" />
								</Grid.ColumnDefinitions>
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto"/>
									<RowDefinition Height="Auto"/>
									<RowDefinition Height="*"/>
								</Grid.RowDefinitions>

								<TextBlock Text="Name"
										   Grid.Row="0"
										   Grid.Column="0"
										   Style="{StaticResource NameStyle}"/>

								<TextBlock
										Text="NewDocument1"
										x:Name="name"
										Grid.Row="0"
										Grid.Column="1"
										Style="{StaticResource ReadOnlyValueStyle}"/>

						

								<TextBlock Text="Status"
										   Grid.Row="1"
										   Grid.Column="0"
										   Style="{StaticResource NameStyle}"/>

								<ribbon:PopupButton Label="Draft"
										FontSize="12"
										Grid.Row="1"
										Grid.Column="1"
										Context="BackstageItem"
										VariantSize="Small"
										Margin="9,-6,0,0"
										Padding="1,0,1,1"
										Foreground="Gray"
										HorizontalAlignment="Left"
										VerticalAlignment="Center"
										VerticalContentAlignment="Center"
										Height="21">
									<ribbon:Menu ItemVariantSize="Small">
										<ribbon:Button Label="Draft"/>
										<ribbon:Button Label="Final"/>
									</ribbon:Menu>
								</ribbon:PopupButton>
							</Grid>
						</DockPanel>

					</ribbon:BackstageTab>
				</ribbon:Backstage>
			</ribbon:Ribbon.ApplicationMenu>

			<ribbon:Ribbon.Tabs>
				<ribbon:Tab Label="Home" KeyTipAccessText="H">
					<ribbon:Group Label="Clipboard" />
					<ribbon:Group Label="Editing" />
				</ribbon:Tab>
			</ribbon:Ribbon.Tabs>
		</ribbon:Ribbon>

		<docking:DockSite
				x:Name="_site"
				x:FieldModifier="public"
				ToolWindowsHaveOptions="False" 
				ToolWindowsHaveTitleBars="True" 
				AreDocumentWindowsDestroyedOnClose="True" 
				CanToolWindowsRaft="False" 
				CanToolWindowsClose="True" 
				CanToolWindowsAutoHide="False"
				AutoHidePerContainer="False">
			<docking:SplitContainer Orientation="Vertical">
				<docking:SplitContainer Orientation="Horizontal">
					<docking:ToolWindowContainer x:Name="_left" docking:DockSite.ControlSize="130, 500" />
					<docking:Workspace>
						<docking:TabbedMdiHost IsImageOnTab="True">
							<docking:TabbedMdiContainer x:Name="_tabbedMdiContainer" />
						</docking:TabbedMdiHost>
					</docking:Workspace>
					<docking:ToolWindowContainer x:Name="_right" docking:DockSite.ControlSize="500, 500" />
				</docking:SplitContainer>
				<docking:ToolWindowContainer x:Name="_bottom" docking:DockSite.ControlSize="500, 100" />
			</docking:SplitContainer>
		</docking:DockSite>
	</DockPanel>
</ribbon:RibbonWindow>

 When i click on any PopupButtom item backstage closing. I expect that menu close on menu item click and backstage don`t.

Comments (2)

Answer - Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Konstantin,

The problem here is that any sort of ribbon:Button click will cause the focus to blur and move back to the main focus scope.  That is happening regardless of if the item is on the ribbon or in a menu.  That focus move triggers the backstage to close.

You can work around it by adding code like this:

<ribbon:Button Label="Draft" StaysOpenOnClick="True" Click="DraftPopupButtonItem_Click"/>
private void DraftPopupButtonItem_Click(object sender, ActiproSoftware.Windows.Controls.Ribbon.Controls.ExecuteRoutedEventArgs e) {
	draftPopupButton.IsPopupOpen = false;
}

The StaysOpenOnClick prevents the menu from closing and doing the focus move.  Then the Click event handler closes the menu.

All that being said (for the current workaround), we agree with you and have updated ribbon:Button for the next maintenance release so that if it is a menu item on a Backstage, it will close the root popup anchor but not the Backstage itself.  This update should roll out soon.


Actipro Software Support

Posted 10 years ago by Konstantin - Edifecs
Avatar

Thanks for you answer.

[Modified 10 years ago]

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

Add Comment

Please log in to a validated account to post comments.