Open stinos opened 1 year ago
Hi @stinos , Thank you for reproting this. Since this issue is hard to reproduce, we can only add more checks in the UpdateContainedFloatingWindowTaskbarTitle() method.
Here's the updated content of the method: ` private void UpdateContainedFloatingWindowTaskbarTitle( bool newValue ) { if( !newValue ) // LayoutContent is being deselected { // Check if LayoutContent is inside a FloatingWindowControl // And set the correct title for Taskbar Title var root = this.Root;
if( (root != null) && (root.Manager != null) )
{
var lfwc = root.Manager.FloatingWindows;
var containedFloatingWindowControl = lfwc.FirstOrDefault( f => (f.Model != null) && f.Model.Descendents().OfType<LayoutContent>().Where( l => l.ContentId == this.ContentId ).FirstOrDefault() != null );
if( containedFloatingWindowControl != null )
{
var selectedLayoutContent = containedFloatingWindowControl.Model.Descendents().OfType<LayoutContent>().Where( l => l.IsSelected ).FirstOrDefault();
if( selectedLayoutContent != null )
{
if( containedFloatingWindowControl.Title != selectedLayoutContent.Title )
{
containedFloatingWindowControl.Title = selectedLayoutContent.Title;
}
}
}
}
}
}`
This will be updated in the next release. Thank you
On my machine this problem is always reproduced when I tried to deserialize layouts.
Target framework is net8.0-windows
and package reference is "Extended.Wpf.Toolkit" Version="4.5.1"
.
Here is a short example.
<Window x:Class="WpfApp1.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:WpfApp1"
xmlns:dock="http://schemas.xceed.com/wpf/xaml/avalondock"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<dock:DockingManager Name="dockingManager">
<dock:LayoutRoot>
<dock:LayoutPanel Orientation="Horizontal">
<dock:LayoutAnchorablePane>
<dock:LayoutAnchorable>
<TextBlock>A</TextBlock>
</dock:LayoutAnchorable>
</dock:LayoutAnchorablePane>
<dock:LayoutDocumentPane>
<dock:LayoutDocument>
<TextBox>X</TextBox>
</dock:LayoutDocument>
</dock:LayoutDocumentPane>
</dock:LayoutPanel>
</dock:LayoutRoot>
</dock:DockingManager>
<Button Height="25" Width="50" Click="Button_Click">Z</Button>
</Grid>
</Window>
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Xceed.Wpf.AvalonDock;
using Xceed.Wpf.AvalonDock.Layout.Serialization;
namespace WpfApp1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
MemoryStream ms = new();
var xs = new XmlLayoutSerializer(dockingManager);
xs.Serialize(ms);
var str = Encoding.Default.GetString(ms.ToArray());
Debug.WriteLine(str);
MemoryStream ms2 = new(Encoding.Default.GetBytes(str));
xs.Deserialize(ms2);
}
}
}
The serialized string written in debug view is
<?xml version="1.0" encoding="utf-8"?>
<LayoutRoot>
<RootPanel Orientation="Horizontal">
<LayoutAnchorablePane>
<LayoutAnchorable AutoHideMinWidth="100" AutoHideMinHeight="100" IsSelected="True" CanClose="False" />
</LayoutAnchorablePane>
<LayoutDocumentPane>
<LayoutDocument IsSelected="True" IsLastFocusedDocument="True" CanClose="True" LastActivationTimeStamp="01/21/2024 16:27:25" />
</LayoutDocumentPane>
</RootPanel>
<TopSide />
<RightSide />
<LeftSide />
<BottomSide />
<FloatingWindows />
<Hidden />
</LayoutRoot>
Hi @czh098tom,
Thank you for your example. Yes, I can reproduce the issue with your sample. But this is already fixed in the latest release, v4.6, which is already available for the user of the Plus Version. This fix will be available in the Community Toolkit version v4.6, which should be released this week. Thank you
This seems to be fixed for us, thanks!
I can unfortunately not provide a minimal example to reproduce because this issue happens rarely, so far never on my machine, and any sample application I tried which resembles the actual application does not exhibit it. So here are just stacktraces, which might help seeing the implementation of UpdateContainedFloatingWindowTaskbarTitle is fairly short. Stacktraces shown from the point where my code calls into AvalonDock code.
Version: 4.5.0. The layout looks like this: