Binding errors when clearing a bound ObservableCollection [Manage C# SDK 2.2.4]
Posted: 17 Oct 2019, 00:36
If I have a List with a bunch of elements...
And an ObservableCollection initialized to that List of items...
Display them in the view...
And then later I clear the collection (or even if I remove them individually):
I get these 4 lines of errors for each items cleared from the collection...
[NOESIS/E] Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='ItemsControl', AncestorLevel='1'
[NOESIS/E] Binding failed: Path=VerticalContentAlignment, Source=null(''), Target=ListBoxItem(''), TargetProperty=Control.VerticalContentAlignment
[NOESIS/E] Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='ItemsControl', AncestorLevel='1'
[NOESIS/E] Binding failed: Path=HorizontalContentAlignment, Source=null(''), Target=ListBoxItem(''), TargetProperty=Control.HorizontalContentAlignment
We do this a lot in our application and so it results in massive amounts of errors streaming by.
Is this a bug in Noesis or is there another way I should be doing this?
Thanks.
Code: Select all
List<string> TestSet1 = new List<string>()
{
"one",
"two",
"three",
"four",
"five",
};
Code: Select all
public ObservableCollection<string> MyCollection { get; }
...
MyCollection = new ObservableCollection<string>(TestSet1);
Code: Select all
<ListBox
Background="White"
ItemsSource="{Binding MyCollection}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<TextBlock Width="206" Height="50" TextAlignment="Left" TextTrimming="CharacterEllipsis" Text="{Binding}" >
</TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Code: Select all
MyCollection.Clear();
[NOESIS/E] Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='ItemsControl', AncestorLevel='1'
[NOESIS/E] Binding failed: Path=VerticalContentAlignment, Source=null(''), Target=ListBoxItem(''), TargetProperty=Control.VerticalContentAlignment
[NOESIS/E] Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='ItemsControl', AncestorLevel='1'
[NOESIS/E] Binding failed: Path=HorizontalContentAlignment, Source=null(''), Target=ListBoxItem(''), TargetProperty=Control.HorizontalContentAlignment
We do this a lot in our application and so it results in massive amounts of errors streaming by.
Is this a bug in Noesis or is there another way I should be doing this?
Thanks.