This project is read-only.

Quick Access Toolbar in 2.0

Oct 9, 2010 at 10:39 PM

I have a collection of QuickAccessMenuItems attached to my ribbon, some of which have IsChecked set, and some of which don't. Now, in 1.3, the checked items appear on the window header by default, and any changes I make to the toolbar get preserved between sessions. In 2.0 however, the checked items don't appear in the toolbar (it appears that space is reserved in design mode, but the icons are not shown, and there is not even space reserved in run mode - you can see the two vertical bars right next to each other). When I bring up the QAT menu, the checked items do not have checkmarks. I can check them and they move up to the toolbar. I can also add other items from the ribbon. But none of it is preserved between sessions.

The Test app QAT DOES work as expected.

Now I've gone through my xaml with a fine tooth comb, but I can't see anything I'm doing differently to the test app, so, frankly, I'm stumped. Any issue what the problem might be? As I say, it works fine in 1.3..


Oct 11, 2010 at 11:35 AM

Does it save minimize/expand of the Ribbon (top-right button) between sessions?

Oct 11, 2010 at 11:37 AM

Any first chance exception in output?

Oct 11, 2010 at 11:49 AM

No, the window state always comes back as Normal in the next session. I don't know if that was true before, since it's not something I've previously tried.

There are no first chance messages generated.

Oct 12, 2010 at 10:52 AM

My Ribbon/QAT code is as follows:


       <Fluent:Ribbon Grid.ColumnSpan="3"  Name="_ribbon"  AutomaticStateManagement="True" CanCustomizeQuickAccessToolBar="True">
                <Fluent:RibbonContextualTabGroup Header="First" Visibility="Visible" x:Name="firstGroup" Background="Green" BorderBrush="Green" />

            <!-- Quick Access Toolbar -->
                <Fluent:QuickAccessMenuItem Target="{Binding ElementName=cmdButtonNew}" IsChecked="True" UseLayoutRounding="True" />
                <Fluent:QuickAccessMenuItem  IsChecked="True">
                    <Fluent:Button Icon="Images\folder.png" LargeIcon="Images\folder.png" Header="Open Flight plan" Click="btnOpenPlanG_Click" ToolTip="Open a flight plan from disc." />
                <Fluent:QuickAccessMenuItem  IsChecked="True">
                    <Fluent:Button Icon="Images\Save.png" Header="Save Flight Plan" Click="btnQATSavePlan" ToolTip="Save the current flight plan." />

                <Fluent:QuickAccessMenuItem  IsChecked="False" >
                    <Fluent:Button Icon="Images\print48.png" Header="Print Map" Click="PrintMap_Click" ToolTip="Prints the current map display." />
                <Fluent:QuickAccessMenuItem IsChecked="False" >
                    <Fluent:Button Icon="Images\print48.png" Header="Print Flight Plan" Click="PrintPlan_Click" ToolTip="Prints the current flight plan." />

and my window code (showing handled events etc:


<Fluent:RibbonWindow x:Class="PlanG.PlanG2010"
    Title="Plan-G" Height="700" Width="1050" MaxWidth="{x:Static SystemParameters.PrimaryScreenWidth}" MaxHeight="{x:Static SystemParameters.PrimaryScreenHeight}" 
    LocationChanged="RibbonWindow_LocationChanged" KeyDown="RibbonWindow_KeyDown" KeyUp="RibbonWindow_KeyUp">

Oct 13, 2010 at 9:24 AM

Looks like a severe bug. If we could repro that... But all our samples and test app works just fine.

Oct 13, 2010 at 2:05 PM

I traced it through, and it seems that when the OnChecked handler is called for the QuickAccessMenuItem, the Target property is null. This means that null is passed to AddToQuickAccessToolBar, so it is not added, and then subsequently set to unchecked.

Maybe it's a timing issue, with Onchecked being called before Target is set?

Oct 16, 2010 at 6:48 PM

I have possibly a related problem with the QAT in my app, although state is saved ok between app sessions.  Sometimes I can add/remove items by right-clicking on them in the main ribbon area, but usually not.  It seems to only work if I haven't done much of anything with the ribbon yet (clicking on items, minimize/restore, etc).  It's very difficult to reproduce in FluentTest, but I have gotten FluentTest to fail after taking many actions.  In the failed state, when right-clicking on an item in the ribbon or the QAT, all context menu items will end up grayed out when they shouldn't be.  There's usually no recovering after this happens, but sometimes if I click enough I can get it to not be grayed out again.

Oct 20, 2010 at 1:55 PM

Further investigation:

1. If I add items to the QAT at runtime, they are correctly written to storage., e.g.

? builder.ToString()

2. On restarting the program, the items are correctly read from storage.


3. ParseAndAddToQuickAccessToolBar fails in the following section:

              object[] children = LogicalTreeHelper.GetChildren(current).OfType<object>().ToArray();
                bool indexIsInvalid = children.Length <= indices[i];
                DependencyObject item = indexIsInvalid ? null : children[indices[i]] as DependencyObject;
                if (item == null)
                    // Path is incorrect
                    Debug.WriteLine("Error while QAT items loading: one of the paths is invalid");

typically because children.Length = 0


This results in the added items being discarded from the toolbar


4. I can make the QAT items that are declared in XAML appear by making the following change in LoadState (between // TWA Change comments):

            // Sync QAT menu items
            foreach (QuickAccessMenuItem menuItem in QuickAccessItems)
                // TWA Change start
                if (menuItem.IsChecked && !IsInQuickAccessToolBar(menuItem.Target))
                // TWA Change end
                menuItem.IsChecked = IsInQuickAccessToolBar(menuItem.Target);

but I don't think this is "a good thing" to do long term.

I hope that gives you something useful to go on.

Oct 21, 2010 at 8:15 AM

However we need repro application (exe) to find what causes it

Oct 21, 2010 at 8:53 AM
Edited Oct 23, 2010 at 10:31 AM

Here you go:

It needs to run on a PC that has access to the Internet, since it uses Google Maps. If you don't have MS flight sim there won't be a lot you can do with it, but should be enough to repro this issue.

Oct 22, 2010 at 11:06 AM

After investigation I have questions:

1) Do you know that AutomaticStateManagement is setted to False in your case? In that mode Ribbon will not preserve state for your app.
2) Styles are applied twice (?) 

Anyway I have added a few changes in the 'state management system', check it, please.


Oct 22, 2010 at 11:08 AM

To Tgrand: what you are describing was fixed lately... check the latest sources if you'll have time...

Oct 22, 2010 at 12:32 PM

Thanks Daniel.

1. Yes; it was one of the things I've been toggling on and off  to see if I could make it work. Wasn't deliberately left off in that build though
2. If you mean the themes (black, blue, silver...) I'm aware it's not checking the style is already applied when it reads settings from the backing store, and that's on my todo list. I don't think I have any other styles that are explicitly set on the ribbon (?)

Having problems with downloads from Codeplex at the moment - the system just times out. Will try again later.

Oct 22, 2010 at 3:30 PM

Thanks again Daniel. This build confirmed working. :-)