Dirkster99 / AvalonDock

Our own development branch of the well known WPF document docking library
Microsoft Public License
1.4k stars 320 forks source link

No header (title) is shown for a LayoutAnchorable #282

Open ShuhuaGao opened 3 years ago

ShuhuaGao commented 3 years ago

Version: 4.51.1 Visual studio 2019 and .Net 5.0

Consider the following simple MWE

<Window x:Class="Dirkster99AvalonDock.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ad="https://github.com/Dirkster99/AvalonDock"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:local="clr-namespace:Dirkster99AvalonDock"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        Title="MainWindow"
        Width="800"
        Height="450"
        mc:Ignorable="d">
    <Grid>
        <ad:DockingManager x:Name="dockManager">
            <ad:LayoutRoot>
                <ad:LayoutPanel Orientation="Vertical">
                    <ad:LayoutDocumentPane>
                        <ad:LayoutDocument Title="doc" CanFloat="True">
                            <Border Background="AliceBlue" />
                        </ad:LayoutDocument>
                    </ad:LayoutDocumentPane>
                    <ad:LayoutAnchorablePane DockHeight="100">
                        <ad:LayoutAnchorable Title="anchorable">
                            <Border Background="Gold" />
                        </ad:LayoutAnchorable>
                    </ad:LayoutAnchorablePane>
                </ad:LayoutPanel>
            </ad:LayoutRoot>
        </ad:DockingManager>
    </Grid>
</Window>

The result is image As shown above, the header of the LayoutAnchorable is not shown, which is supposed to display the title. Is this a bug, or did I miss anything?

[NOTE] If I simply change the avalon dock to the one in xceed wpftookit, then the title of the anchorable pane is shown as expected. Snipaste_2021-06-28_19-26-54

ShuhuaGao commented 3 years ago

Update

The previous version v4.50.3 on NuGet has no problem. Thus, a bug was introduced after v4.50.3.

The following screenshot was obtained with v4.50.3 image

ShuhuaGao commented 3 years ago

Update 2

I tested AvalonDock PRE-VIEW Version 4.51.0. It worked as expected.

Now we can see that a bug happened in exactly v 4.51.1.

ShuhuaGao commented 3 years ago

Update 3

The bug is caused by commit c15f83c. If we remove the x:Key="AnchorablePaneTitleStyle", then everything works normally.

Please check #266.

Akeloya commented 3 years ago

Update

The previous version v4.50.3 on NuGet has no problem. Thus, a bug was introduced after v4.50.3.

The following screenshot was obtained with v4.50.3

You saved my time! Rollback from 4.51.1 to 4.50.3 solved problem with visibility header of anchorable pane

KingSB60 commented 3 years ago

@ShuhuaGao @Dirkster99 I figured out that the style for the AnchorablePaneTitle is also defined in the corresponding Themes.xaml of each theme project. Maybe we have to introduce the x:Key="AnchorablePaneTitleStyle" in each of these Themes.xaml to see the anchorables title at all circumstances => I Didn't try that!

hupo376787 commented 3 years ago

I met this problem now, removing x:Key="AnchorablePaneTitleStyle" works fine for me.

Hope the author can solve this soon.

Dirkster99 commented 3 years ago

mhh, I am not sure what the best fix is here?

Do you want me to:

1) remove the x:Key="AnchorablePaneTitleStyle" ? This would undo the point of the original PR, which was to make this overridable :-(

2) apply the same x:Key="AnchorablePaneTitleStyle" to other themes so its consistent?

3) Do you see an alternative solution to make this overridable as intended in the original PR but use a different approach for it?

4) perform an alternative solution?

hupo376787 commented 3 years ago

I'm a newbie. But the original pr set the key, he should override in his own project, place x:Key="AnchorablePaneTitleStyle" in his own App.xmal.

Dirkster99 commented 3 years ago

OK, so this issue can be closed then, right?

hupo376787 commented 3 years ago

So any advice, @zcanann ?

zcanann commented 3 years ago

WPF isn't my specialty -- if the recommendation works to "place x:Key="AnchorablePaneTitleStyle" in my own App.xmal." then I can live with that.

hupo376787 commented 3 years ago

So is there any way that we can custom the pane title? @Dirkster99

hausgh commented 3 years ago

Maybe defining a style based on AnchorablePaneStyle for AnchorablePaneTitle would do the trick.

<Style x:Key="AnchorablePaneTitleStyle" TargetType="{x:Type avalonDockControls:AnchorablePaneTitle}">
        .....
</Style>
<Style TargetType="{x:Type avalonDockControls:AnchorablePaneTitle}" BasedOn="{StaticResource AnchorablePaneTitleStyle}"/>

This way default style will be applied when no customization needed and no additional entries in app.xaml Customizing the pane title then can be done by placing a custom style based on AnchorablePaneStyle in app.xaml

<Style TargetType="{x:Type avalonDockControls:AnchorablePaneTitle}" BasedOn="{StaticResource AnchorablePaneTitleStyle}">
        ... custom styling here ...
</Style>

To make things consistent all themes should be modified this way.

LamerTex commented 3 years ago

WPF isn't my specialty -- if the recommendation works to "place x:Key="AnchorablePaneTitleStyle" in my own App.xmal." then I can live with that.

I'm having the same problem after updating the NugetPackage to the latest version, I'm trying to solve it like you guys are saying, but I'm really a noob with WPF. What exactly placing the "x:Key="AnchorablePaneTitleStyle" in my own App.xaml" means? Should I add an empty "Style" with that name? Doing just that doesn't fix the problem in my case... Should I put something in that Style? maybe a "BasedOn" some other style already present in the AvalonDock namespace to have the title and "x" to close like it was before?

Thanks for your help!

dfraska-ftl commented 3 years ago

Here's the workaround that worked for me, since it wasn't very clear from the previous comments:

In app.xaml:

Add the namespace

    xmlns:avalon="https://github.com/Dirkster99/AvalonDock"

Then, create a default style for the AnchorablePaneTitle based on AnchorablePaneTitleStyle

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/AvalonDock;component/Themes/generic.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <Style TargetType="{x:Type avalon:AnchorablePaneTitle}"
                   BasedOn="{StaticResource AnchorablePaneTitleStyle}"/>
        </ResourceDictionary>
    </Application.Resources>
nzain commented 2 years ago

We're facing the same issue after upgrading (title bar and buttons missing on Anchroables) and I don't quite understand the problem / what would be the right way for us. Is the title bar (intentionally) invisible by default now?

We're already overriding the DockingManager.AnchorableTitleTemplate to slightly modify the style of the title bar. This was possible for a long time - what exactly is the x:Key="AnchorablePaneTitleStyle" meant for and how would we use it? Maybe this is what we should be using now? Sorry for the confusion.