Fix for debug output errors
Add the follow lines to the file App.xaml
in your WPF application
<!--
Global fix for
System.Windows.Data Error: 4 :
Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ItemsControl', AncestorLevel='1''.
BindingExpression:Path=HorizontalContentAlignment; DataItem=null;
target element is 'ComboBoxItem' (Name='');
target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')
System.Windows.Data Error: 4 :
Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ItemsControl', AncestorLevel='1''.
BindingExpression:Path=VerticalContentAlignment; DataItem=null;
target element is 'ComboBoxItem' (Name='');
target property is 'VerticalContentAlignment' (type 'VerticalAlignment')
-->
<Application.Resources>
<Style TargetType="ComboBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
</Application.Resources>
Thanks, this is still a fix as of today (.NET 9). In my case, the exceptions occur when I change the SortDescriptions of a CollectionViewSource at runtime and that makes the application totally unresponsive (the weird thing is it does not happen when the collection is first loaded, only when its sort order is modified).