简体   繁体   中英

Ribbon application menu (dropdown) is not minimizing (closing or losing focus) in WPF application while loading after a click event

I have a wpf application with ribbon included. The ribbon has application menu which is a dropdown like this image . This application menu has list of recent file for opening a file like this . Now when a user select one recent file from the list, this dropdown get stuck until the file is loaded. The dropdown comes on top of any other application like powerpoint if I open it parallelly while the file is being loaded like this . I want the dropdown to close while the file is being loaded so that I can show some progress bar or loading icon.

The xaml code is given below.

<Ribbon>
        <Ribbon.ApplicationMenu>
            <RibbonApplicationMenu >
                <RibbonApplicationMenu.AuxiliaryPaneContent>
                    <StackPanel>
                        <TextBlock Text="{DynamicResource Recent}" />
                        <Separator />
                        <RibbonGallery
                            CanUserFilter="False"
                            ScrollViewer.VerticalScrollBarVisibility="Auto">
                            <RibbonGalleryCategory Background="Transparent" ItemsSource="{Binding RecentFiles}">
                                <RibbonGalleryCategory.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <StackPanel IsItemsHost="True" Orientation="Vertical" />
                                    </ItemsPanelTemplate>
                                </RibbonGalleryCategory.ItemsPanel>
                                <RibbonGalleryCategory.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <Grid.InputBindings>
                                                <MouseBinding
                                                    Command="{Binding DataContext.opencommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
                                                    CommandParameter="{Binding FilePath}"
                                                    MouseAction="LeftClick" />
                                            </Grid.InputBindings>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="*" />
                                            </Grid.ColumnDefinitions>

                                            <TextBlock Text="{Binding Numero}" TextDecorations="Underline" />
                                            <TextBlock
                                                Grid.Column="1"
                                                Margin="0,0,10,0"
                                                Text="{Binding FileName}"
                                                TextTrimming="CharacterEllipsis"
                                                ToolTip="{Binding FilePath}" />
                                        </Grid>
                                    </DataTemplate>
                                </RibbonGalleryCategory.ItemTemplate>
                            </RibbonGalleryCategory>
                        </RibbonGallery>
                    </StackPanel>
                </RibbonApplicationMenu.AuxiliaryPaneContent>
            </RibbonApplicationMenu>
        </Ribbon.ApplicationMenu> >
    </Ribbon>

Please help me with any idea. I tried replacing textblock with ribbonbutton but the click event was not working. Any help is appreciated.

Thanks

Bind a boolean to Ribbon.IsDropDownOpen and set it false before loading the file. Maybe you'll have to use the Dispatcher to make it work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM