NavigationBarLayoutSerializer fails

Navigation for WPF Forum

Posted 10 years ago by Markus Springweiler
Version: 9.2.0513
Avatar
Hello,

maybe I'm just doing something wrong:
In the constructor of the window (after InitializeComponent) I have this code:

            foreach ( var mod in modules )
            {
                var pane = mod.Attribute.GetNavPane(this);
                pane.Title = mod.Attribute.GetTitle();
                pane.Name = mod.Type.FullName.Replace('.', '_');
                Trace.WriteLine(pane.Name, "add");
                this.navBar.Items.Add(pane);
            }

            if ( Settings.Default.NavigationBarLayout != null )
            {
                var serializer = new NavigationBarLayoutSerializer(Settings.Default.NavigationBarLayout);
                try
                {
                    serializer.ApplyTo(this.navBar);
                }
                catch ( Exception ex )
                {
                    Trace.TraceError(ex.ToString());
                }
            }
and when closing the window I'm serializing it this way (into Settings.settings file, property is of type XmlNavigationBarLayout:

            var serializer = new NavigationBarLayoutSerializer();
            Settings.Default.NavigationBarLayout = serializer.CreateRootNodeFor(this.navBar);
The problem is that serializer.ApplyTo(this.navBar) fails, but the message is silly since it's a lie -- do I have to call something on this.navBar for the dynamically added items to be registered in some dictionary?

The output of the constructor Trace.WriteLine/.TraceError is the following:

add: MyApp_SimpleWeekViewDocWin
add: MyApp_ProjektPlanerDocWin
MyApp.vshost.exe Error: 0 : System.Runtime.Serialization.SerializationException: No NavigationPane could be found with the Name 'MyApp_SimpleWeekViewDocWin'.
   bei ActiproSoftware.Windows.Controls.Navigation.Serialization.NavigationBarLayoutSerializer.a(NavigationBar A_0, XmlNavigationPane A_1)
   bei ActiproSoftware.Windows.Controls.Navigation.Serialization.NavigationBarLayoutSerializer.a(NavigationBar A_0, XmlNavigationBarLayout A_1)
   bei ActiproSoftware.Windows.Controls.Navigation.Serialization.NavigationBarLayoutSerializer.ApplyTo(NavigationBar obj)

Comments (3)

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

For things like this, please put together a small sample project that reproduces the issue and email it over to our support address. That would allow us to better see what's going on and debug any issues. Thanks.


Actipro Software Support

Posted 10 years ago by Markus Springweiler
Avatar
I'll do this as soon as I have some spare time.

Using SaveToString/LoadFromString works well.

BTW: Using DockSiteLayoutSerializer and assigning the result of CreateRootNodeFor (which
looks good while debugging) to a property auto-created by settings.settings results in nothing which gets written to user.config, on reload the property is null again.
Posted 10 years ago by Markus Springweiler
Avatar
I'll do this as soon as I have some spare time.

Using SaveToString/LoadFromString works well.

BTW: Using DockSiteLayoutSerializer and assigning the result of CreateRootNodeFor (which
looks good while debugging) to a property auto-created by settings.settings results in nothing which gets written to user.config, on reload the property is null again.
The latest build of this product (v2019.1 build 0681) 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.