npolyak / NP.Ava.UniDock

New (Avalonia 11) UniDock repository
MIT License
154 stars 10 forks source link

Losing style properties whenever DockItem is undocked #18

Closed Artur-CValente closed 8 months ago

Artur-CValente commented 8 months ago

Hey, first and foremost I'd like to thank you @npolyak for developing this tool for free, your effor doesn't go unnoticed. I'm new to avalonia, wpf, c#, the whole package, so maybe I'm just doing something wrong. The problem is the following: I've setted some styles in my user control and it works just fine when all the dockitems are docked, but whenever I float the dockitem it loses those style properties, I hadn't noticed it before today when I changed my ToggleButtons to ListBoxes so maybe it's this. I'll give some snippets of my code: This is the styling I'm trying to apply: Captura de tela 2024-02-20 193438

This is a ListBox That i'm also styling in place: Captura de tela 2024-02-20 195449

This is one that i'm not styling in place just the user control defined styles should apply: Captura de tela 2024-02-20 195522

A video illustrating the issue.

https://github.com/npolyak/NP.Ava.UniDock/assets/160673610/72440d4c-c8d0-47e4-b172-2c32ca991ac3

Some notes, as you may notice the first row works fine when it floats because I've tried copied the styles I have in the in it's . Also another important point is that when I re-dock it, it turns back to the normal appearance as shown in the end of the video. The last thing, there seens to be some issue when recording the screen and docking at the same time, it has happened to me before when I shared my screen over teams and the docking wouldn't work, now when trying to record I've got the same problem, but that's another issue. Any help is appreciated.

npolyak commented 8 months ago

Thanks Artur, Try to put your styles in the Resources section of App.axaml file and not in the file that defines the RootDockGroup. If it does not help, create project that I can compile and run in some public Github repostory, send me a link to it and I'll take a look on Sunday.

StefanKoell commented 8 months ago

I'm actually seeing the same thing. Styles change when a tab has been pulled out to a floating panel. All styles are set by the theme or by assigned classes where the styles have been defined in the app.axaml.

Artur-CValente commented 8 months ago

That did the job, would you care to explain to me how did you know that putting the styles in the app.axaml would work? I mean is it because of some particular implementation of UniDock, or is it some default behavior of things in Avalonia, like the way the logical control tree or resources priority work. Nevertheless, thank you very much, your help was much appreciated.

npolyak commented 8 months ago

Sure - app.axaml is visible from every other XAML file within the application. So every window can apply the styles and resources from there to itself. While the stuff defined in the MainWindow might not be visible by other windows.

npolyak commented 8 months ago

@StefanKoell try to do the same as Artur - it worked for him.

StefanKoell commented 8 months ago

@npolyak that's the strange thing. I already have all styles setup in the app.axaml and while most styles are preserved a couple of styles are either lost or overwritten. I will do some digging and provide a sample app.