MaterialDesignInXAML / MaterialDesignInXamlToolkit

Google's Material Design in XAML & WPF, for C# & VB.Net.
http://materialdesigninxaml.net
MIT License
15.06k stars 3.41k forks source link

TabControl selection changes triggers with no reason. #3337

Closed Drexel2k closed 11 months ago

Drexel2k commented 11 months ago

Bug explanation

Hello,

I am not quite sure, if this is a bug or I am overseeing something damn stupid.

I have a TabControl with ToolBarTrays with some buttons in the TabItems. When I click on a Tab, then to another tab and click on a button it switches back to the last tab.

I build a minimal example for it. In my real app, this happens only one time or is prevented when i click a sencond time on the current tab. In the minimal example, it happens all the time.

Steps to reproduce:

  1. Start the app with Debug/AnyCPU.
  2. Click on Playlists tab.
  3. Click on Templates tab.
  4. Click there on the New Template Button.

Now it switches back to Playlists Tab, also the SelectionChanged fires, you can set a breakpoint on the event listener in the MainWindopws.xaml.cs on line 19. In my real MVVM app, also the TabIndex binding triggers.

You can download the minimal example here: https://1drv.ms/f/s!AlNGd4g1Vh9rnRPpOFeQeEcRB1Dw?e=gTFxms

Thank you in advance for your help! Best regards Matthias

Version

4.9.0

Drexel2k commented 11 months ago

Ok, I took out the MaterialDesign components and the problem still exists.... Doesn't seem to be Material related.

Drexel2k commented 11 months ago

When I remove the ToolBarTrays everything works fine.

nicolaihenriksen commented 11 months ago

@Drexel2k very interesting application behavior! I tried your sample and could easily reproduce the issue. Looking at the callstack when the tab changes unexpectedly, I suspect it could have something to do with mouse capturing (used for drag/drop of toolbar items inside of the toolbar). I am not sure though, it is just a gut feeling.

Nevertheless, this does not seem related to MDIX since it reproduces without the nuget even being pulled in, so you should probably close this issue, and raise one here instead?

Drexel2k commented 11 months ago

I will do, thanks for your feedback!