Serializing the QAT

Ribbon for WPF Forum

Posted 15 years ago by Magnus Eklof
Version: 4.5.0486
Avatar
Hi,

I have a problem serialize/deserialize the QAT if it contains our own commands (inherited from RoutedUICommand) and I suspect there is (in part at least) a namespace problem.

This is what a serialized command looks like
            <RibbonControlPathItem.Instance>
                <ribbon:Button Context="QuickAccessToolBarItem" Id="New" VariantSize="Small">
                    <ribbon:Button.Command>
                        <av:RoutedUICommand Text="_Ny" />
                    </ribbon:Button.Command>
                </ribbon:Button>
            </RibbonControlPathItem.Instance>
it looks like it lacks some things, I did a test editing the xml before starting the app as such:
            <RibbonControlPathItem.Instance>
                <ribbon:Button Command="f:FastNetCommands.New" Context="QuickAccessToolBarItem" Id="New" VariantSize="Small">
                </ribbon:Button>
            </RibbonControlPathItem.Instance>
and also included our namespace:
xmlns:f="http://schemas.agresso.se/FastNet"
and it worked fine DeSerializing this into the ribbon.

Any ideas about this?

Regards
/Magnus

Comments (3)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Magnus,

Can you email over a simple sample project that shows the issue happening and we'll debug it to see what can be done? Thanks!


Actipro Software Support

Posted 15 years ago by Magnus Eklof
Avatar
Thanks, I have emailed a testproject to the support address.
Posted 15 years ago by Magnus Eklof
Avatar
Pasting the response for others...

Magnus,

The main problem here is that XAML serialization (Microsoft's code) which is what we use to serialize the the QAT data, doesn't retain a static reference to your command. When it pulls in your command initially, the command is then set on the Command property and all ties to the static MyCommands class are gone. Thus it is serialized as a normal RoutedUICommand that is not tied back up to the MyCommands instance when deserialized. You can see this in the XML.
When you load the XML back, it is creating your button and loading the "unattached" command from the XML properly. However since that "unattached" command doesn't have a handler, the button is disabled and therefore appears like whitespace (since the "unattached" command isn't pulling your UI either).
What you may need to do is reattach the proper commands after deserilizing the QAT. Either that or modify your XML manually so you add a namespace ref to the namespace that contains MyCommands and change the Command value on the button so it references that. Alternatively try and find a way to serialize the reference to your MyCommands class via some other way of specifying the command in your original XAML, but so far our tests haven't found a way to do that.
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.