Closed TomEdwardsEnscape closed 1 year ago
There are 2 parts to this I think:
ItemsSource
, but Items
is untyped and can contain any data type. This can be fixed by adding x:DataType
, i.e.:<TabControl SelectedValue="Leaf" SelectedValueBinding="{Binding Header}" x:DataType="TabItem">
SelectedItemsControl.BindingHelper.Evaluate
doesn't accept a null data context. I think this is a mistake. If one removes this restriction, then everything works as expected. Will open a PR.
Describe the bug The
SelectedValue
system does not function when aTabControl
contains items defined in XAML, through eitherItems
orItemsSource
.It's common in our WPF codebase to have multiple tab pages and display the one tagged with the value provided by an enum property on the viewmodel. This bug prevents us from replicating that design in Avalonia.
To Reproduce Open
samples\ControlCatalog\Pages\TabControlPage.xaml
and change the firstTabControl
(currently line 25) so that it has these property values:This will not compile due to an error in the compiled binding system:
Switch to
ReflectionBinding
and you will be able to build, but this exception will be thrown on startup:Expected behavior The
TabControl
starts with the secondTabItem
(header "Leaf") selected. IfSelectedValue
changes, so does the active tab.