during application run-time, I encountered the following errors: 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 'ListViewItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')
I tried to add the following Style code lines, but unfortunately it did not help. Any ideas?
code:
<ListView Visibility="{Binding Path=IsListDisplayed, Converter={StaticResource BooleanToVisConverter}}"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Grid.Row="1"
ItemsSource="{Binding JobsList}"
SelectedItem="{Binding SelectedJob}"
x:Name="JobsLv">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<avt_controls:VirtualizingWrapPanel/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Border BorderThickness="4" CornerRadius="10" Margin="10">
<Border.Style>
<Style TargetType="{x:Type Border}">
<Style.Triggers>
<DataTrigger Binding="{Binding JobStatus}" Value="Ready">
<Setter Property="BorderBrush" Value="Green"/>
</DataTrigger>
<DataTrigger Binding="{Binding JobStatus}" Value="FromMIS">
<Setter Property="BorderBrush" Value="Blue"/>
</DataTrigger>
<DataTrigger Binding="{Binding JobStatus}" Value="InProgress">
<Setter Property="BorderBrush" Value="Red"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding JobName}" Grid.Row="0" FontSize="13" Margin="5,0,0,0"/>
<TextBlock Text="{Binding LastUpdate, StringFormat={}{0:dd/MM/yyyy hh:mm}}" Grid.Row="1" FontSize="13" Margin="5,0,0,0"/>
<ListView Grid.Row="2" ItemsSource="{Binding Designs}" BorderBrush="Transparent" Background="Transparent" Margin="3">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"></StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Image Width="100" Margin="1">
<Image.Style>
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsDownloading}" Value="True">
<Setter Property="Source" Value="{Binding ThumbnailFilePath}"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsDownloading}" Value="False">
<Setter Property="Source" Value="{Binding ThumbnailFilePath}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
HorizontalContentAlignment
, but I don't see any mention of that in your code. Could you please update the question if this has changed? Thanks. – Mike Eason