I get:
System.Windows.Data Error: 40 : BindingExpression path error: 'State' property not found on 'object' ''PointNetObject' (HashCode=9270846)'. BindingExpression:Path=State; DataItem='PointNetObject' (HashCode=9270846); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
for one column. All the rows are added to table, but for each row i get the error. Two other columns are displayed just fine for each row. But not the State. Naturally the converter is never called.
Set-up described below.
I have an object:
public class PointNetObject : NetObject
{
SwitchObjectState State
{
get { return _state; }
set { _state = value; }
}
}
which inherits class that has properties like Phase and Label
In ViewModel:
public ObservableCollection<PointNetObject> SelectedSwitchItems { get; private set; }
public SelectedObjectsViewModel(SelectedObjects selectedObjects)
{
SelectedSwitchItems = new ObservableCollection<PointNetObject>(GetSwitches());
}
IEnumerable<PointNetObject> GetSwitches()
{
foreach (var netObject in SelectedObjectsInstance.GetSelectedObjectItems(x => IsSwitch(x)))
{
yield return (PointNetObject) netObject;
}
}
in View:
<DataGrid Name="SelectedSwitchesGrid" CanUserAddRows="False" CanUserResizeColumns="True" CanUserSortColumns="True" IsReadOnly="True"
ItemsSource="{Binding SelectedSwitchItems}"
<DataGrid.Columns>
<DataGridTextColumn Header="{DynamicResource XpStrLabel}" Binding="{Binding Label}" />
<DataGridTextColumn Header="{DynamicResource XpStrPhase}" Binding="{Binding Phase}" />
<DataGridTextColumn Header="{DynamicResource XpStrState}" Binding="{Binding State, Converter={StaticResource SwitchObjectStateToStringConverter}}" />
</DataGrid.Columns>
</DataGrid>
SwitchObjectState State
property isn'tpublic
, which is, like, pretty important. – Jonesopolis