
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 'ListBoxItem' (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 'ListBoxItem' (Name=''); target property is 'VerticalContentAlignment' (type 'VerticalAlignment')
Here is my markup:
<Window x:Class="Chevron.Dpe.Presentation.Views.CustomUnitsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:actipro="http://schemas.actiprosoftware.com/winfx/xaml/views"
xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
xmlns:views="clr-namespace:Chevron.Dpe.Presentation.Views"
Title="Custom Units"
Width="700"
Height="450"
WindowStartupLocation="CenterOwner">
<DockPanel>
<StackPanel Margin="3" HorizontalAlignment="Center" DockPanel.Dock="Bottom" Orientation="Horizontal">
<Button Width="50" Margin="3" Click="OkClick" Content="OK" />
<Button Width="50" Margin="3" Click="CancelClick" Content="Cancel" />
<shared:PopupButton Width="105" Margin="3" Content="Default this to..." DisplayMode="Merged">
<shared:PopupButton.PopupMenu>
<ContextMenu>
<MenuItem Command="{Binding Path=BaseOnCommand}" CommandParameter="Field" Header="Field" />
<MenuItem Command="{Binding Path=BaseOnCommand}" CommandParameter="Metric" Header="Metric" />
<MenuItem Command="{Binding Path=BaseOnCommand}" CommandParameter="Si" Header="Si" />
</ContextMenu>
</shared:PopupButton.PopupMenu>
</shared:PopupButton>
</StackPanel>
<Border Margin="3">
<ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto">
<ItemsControl BorderBrush="DarkSlateGray" BorderThickness=".5" ItemsSource="{Binding Path=DomainRows}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<actipro:AnimatedWrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Width="90" Margin="3" Padding="2" Text="{Binding Path=Description}" />
<shared:RadioButtonList Width="100"
Margin="3"
BorderBrush="#FF828790"
BorderThickness="1"
DisplayMemberPath="ShortName"
ItemsSource="{Binding Path=Units}"
SelectedItem="{Binding Path=SelectedUnit}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Border>
</DockPanel>
</Window>