Noesis reporting numerous errors/warnings about binding failures but working correctly
Posted: 10 Jun 2020, 09:59
I'm getting a number of errors such as:
[NOESIS/W] Type 'Tests.ViewModel' does not contain a property named 'Row'
[NOESIS/E] Binding failed: Path=Row, Source=Tests.ViewModel(''), Target=ContentPresenter(''), TargetProperty=Grid.Row
[NOESIS/W] Type 'Tests.ViewModel' does not contain a property named 'Column'
[NOESIS/E] Binding failed: Path=Column, Source=Tests.ViewModel(''), Target=ContentPresenter(''), TargetProperty=Grid.Column
Here is a small project created to demonstrate the issue. I create a 2x2 ItemsControl Grid. It binds to a list of items. And the Row/Column where each item should be placed is specified in the item itself.
The program functions as it should and the databinding works as it should. The only issue are the errors. I'm seeing a very large number of errors/warnings along these lines in the main project and presumably unnecessary binding attempts.
[NOESIS/W] Type 'Tests.ViewModel' does not contain a property named 'Row'
[NOESIS/E] Binding failed: Path=Row, Source=Tests.ViewModel(''), Target=ContentPresenter(''), TargetProperty=Grid.Row
[NOESIS/W] Type 'Tests.ViewModel' does not contain a property named 'Column'
[NOESIS/E] Binding failed: Path=Column, Source=Tests.ViewModel(''), Target=ContentPresenter(''), TargetProperty=Grid.Column
Here is a small project created to demonstrate the issue. I create a 2x2 ItemsControl Grid. It binds to a list of items. And the Row/Column where each item should be placed is specified in the item itself.
Code: Select all
<ItemsControl ItemsSource="{Binding ItemList}">
<ItemsControl.DataContext>
<local:ViewModel/>
</ItemsControl.DataContext>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Label Content="{Binding Name}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Grid.Row" Value="{Binding Row}"/>
<Setter Property="Grid.Column" Value="{Binding Column}"/>
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
Code: Select all
class ViewModel
{
public ObservableCollection<Item> ItemList { get; } = new ObservableCollection<Item>();
public ViewModel()
{
ItemList.Add(new Item());
}
}
class Item
{
public int Column { get; } = 1;
public int Row { get; } = 1;
public string Name => $"[{Column},{Row}]";
}