enisn / UraniumUI

Uranium is a Free & Open-Source UI Kit for MAUI.
Apache License 2.0
1.17k stars 142 forks source link

Binding TabItem.Title property to ViewModel property throws exception #720

Open BeepBeepBopBop opened 3 months ago

BeepBeepBopBop commented 3 months ago

Hello, I am trying to bind the title of a tab item to a property but this does not work.

The following exception gets thrown: {"Operation is not valid due to the current state of the object."}

You can reproduce the issue with the following line (the page has toi be bound to ViewModelObject of course):

            <material:TabItem Title="{Binding Source={RelativeSource AncestorType={x:Type vm:ViewModelObject}}, Path=PropertyA}">

Thanks for any help

enisn commented 3 months ago

Can you provide more information about the exception stacktrace? Also which platform do yo face this issue?

enisn commented 3 months ago

I reproduced the same problem on Windows

   at Microsoft.Maui.Controls.Binding.<ApplyRelativeSourceBinding>d__27.MoveNext()
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.<>c__DisplayClass2_0.<Post>b__0()
JorisZwaenepoel commented 2 months ago

I'm trying to fill in the title of a tabitem using a Binding, but this doesn't work at all. I do not get this exception. The property getter on the ViewModel is not called. There is no error in de XAML Binding Failures window.

What would you recommend if I need to change the title in runtime (for translation reasons)?