Closing the backstage

Ribbon for WPF Forum

Posted 6 years ago by Moondance
Version: 13.1.0581
Avatar

I created a new tab for the backstage. In this tab I have a listbox and a button.

The button is a ribbon:Button and through its StaysOpenOnClick property I am able to determine whether the backstage should close or not.

The listbox is a WPF listbox. I have a command configured on the PreviewMouseLeftButtonUp.

I want to be able to close the the Backstage when the event is handled. The event handler receives the backstage as argument but it does not seem to be useful.

Code snippet below:

 <ListBox SelectionMode="Single" ItemsSource="{Binding MyList,Mode=OneWay}" SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}"

ItemContainerStyle="{StaticResource MyLookStyle}">  <-- This is my style

<MyCmd:EventBehaviorCollection.Behaviors>

<MyCmd:EventCommandBinding EventName="PreviewMouseLeftButtonUp" Command="{Binding OpenMyCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ribbon:Backstage}}}"/>

</shellCmd:EventBehaviorCollection.Behaviors>

<ListBox.ItemTemplate>

<DataTemplate>

<StackPanel Orientation="Horizontal">

<Image Width="25" Height="25" Margin="5" HorizontalAlignment="Center" Style="{StaticResource iconImageStyle}"/>

<TextBlock Text ="{Binding Name}" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock> </StackPanel>

</DataTemplate>

</ListBox.ItemTemplate>

</ListBox>

 

 

Any way you can help me with this?

Comments (6)

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

Hello... I'm sorry but I'm not quite sure what you are trying to do here.  Could you explain in a bit more detail?  Thanks!


Actipro Software Support

Posted 6 years ago by Moondance
Avatar

Basicaly I have a listbox and when the user selects an item on it I want to leave the backstage. The listbox is a WPF listbox so it does not have the "StaysOpenOnClick" property (the list contains the Most recently items a user can choose from to open a document). The ribbon:button has that property and when I set it to false I see the backstage closing, when I set it to true I see that the backstage does not close. I want to do the same with the listbox/listboxitem.

Posted 6 years ago by Moondance
Avatar

Actually I am changing my approach. I decided I want to use the RecentDocumentMenu and RecentDocumentManager in my Backstage Recent tab instead of using my own control (which work fime except that I cannot close the backstage). But I need to use the MVVM pattern and I am not sure how the binding should look like. The example in Quickstart is not MVVM. Do you have anything of that sort you could share?

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

Hello,

Sorry we don't have anything that can be applied to ListBox or ListItems.  If you want to close the backstage programmatically though, just set Ribbon.IsApplicationMenuOpen = false.  Then you can use your original ListBox approach.


Actipro Software Support

Posted 6 years ago by Moondance
Avatar

I decided to use the RecentDocumentMenu and Manager. Since it needed to look quite different from the default one I changed the template as needed. I have only one more thing to do. I like the pinning functionality but I would like to capture that event in my ViewModel. From the xaml I see that it the pin button executes

<Setter Property="Command" Value="{x:Static Input:RibbonCommands.TogglePin}" />.

I cannot change that, but I would like to register for a document pinned event so that I can do some processing. I have no clue on how to do that. Any suggestion?

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

We don't have an event for that but you could make an attached behavior.  Basically make an attached property and set that property in a Setter of that pin button.  Then in the property changed handler for the attached property attach to the click event of the target button and do your processing there.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) 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.