Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

Created Unassigned: AvalonDock: Can't add new LayoutDocuments to a LayoutDocumentPane after deserializing [22529]

$
0
0
Being able to add new LayoutDocuments to a LayoutDocumentPane by using code behind (pane.Children.Add() stops working after you deserialize a layout.

Simple repro follows. Using the "Add new tab" button will stop working after clicking the "Deserialize" button. Even if re-serializing and deserializing, the new tabs are not visible.

Repro XAML:

```
<Window x:Class="AvalonDockTabsTest2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:AvalonDockTabsTest2"
xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0"
Orientation="Horizontal">
<Button Content="Add new tab"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Margin="4"
Click="OnAddTabClick" />
<Button Content="Serialize"
Margin="4"
Click="OnSerialize" />
<Button Content="Deserialize"
Margin="4"
Click="OnDeserialize" />
</StackPanel>
<xcad:DockingManager Grid.Row="1" x:Name="DockingManager">
<xcad:LayoutRoot>
<xcad:LayoutPanel>
<xcad:LayoutDocumentPaneGroup>
<xcad:LayoutDocumentPane x:Name="DocPane">
<xcad:LayoutDocument Title="Default" CanClose="False" />
</xcad:LayoutDocumentPane>
</xcad:LayoutDocumentPaneGroup>
</xcad:LayoutPanel>
</xcad:LayoutRoot>
</xcad:DockingManager>
</Grid>
</Window>
```

Repro code-behind:

```
namespace AvalonDockTabsTest2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private int count;
private string serializedLayout;

public MainWindow()
{
this.InitializeComponent();
}

private void OnAddTabClick(object sender, RoutedEventArgs e)
{
LayoutDocument doc = new LayoutDocument();
doc.Title = "test " + this.count;
doc.ContentId = "test" + this.count;
doc.Content = new Grid();
++this.count;
this.DocPane.Children.Add(doc);
}

private void OnDeserialize(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(this.serializedLayout))
{
this.OnSerialize(null, null);
}

XmlLayoutSerializer serializer = new XmlLayoutSerializer(this.DockingManager);
using (StringReader sr = new StringReader(this.serializedLayout))
{
XmlReader xr = XmlReader.Create(sr);
serializer.Deserialize(xr);
}
}

private void OnSerialize(object sender, RoutedEventArgs e)
{
XmlLayoutSerializer serializer = new XmlLayoutSerializer(this.DockingManager);
using (MemoryStream ms = new MemoryStream())
{
serializer.Serialize(ms);
this.serializedLayout = Encoding.ASCII.GetString(ms.ToArray());
}
}
}
}
```

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>