I am working on a large WPF project and during debug my output window is filled with these annoying warnings:
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid > fallback value exists; using default instead. BindingExpression:Path=HorizontalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'HorizontalContentAlignment' (type >' HorizontalAlignment')
In the specific example ComboBoxItem is styled in this way:
<Style x:Key="{x:Type ComboBoxItem}" TargetType="{x:Type ComboBoxItem}">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Border
Name="bd"
Padding="4,4,4,4"
SnapsToDevicePixels="True"
CornerRadius="2,2,2,2">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsHighlighted" Value="true">
<Setter TargetName="bd" Property="Background" Value="{StaticResource MediumBrush}"/>
<Setter TargetName="bd" Property="Padding" Value="4,4,4,4"/>
<Setter TargetName="bd" Property="CornerRadius" Value="2,2,2,2"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I know that the problem is generated by the default theme definition for ComboBoxItem that contains things like:
<Setter Property="Control.HorizontalContentAlignment">
<Setter.Value>
<Binding Path="HorizontalContentAlignment" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
</Setter.Value>
</Setter>
but I also thought that using
<Setter Property="OverridesDefaultStyle" Value="True"/>
would taken care of the problem, and instead warnings are still there.
EDIT: In order to reproduce the problem you need to override also the style of ComboBox exactly like done in this example from MSDN: ComboBox ControlTemplate Example
Any help is really appreciated