I have an ObservableCollection bound to a DataGrid and everything works fine. I want to filter the collection without going to the database repeatedly so I decided to use a backing collection to store the original list and then publicly expose the filtered list to the binding. So I have the following code:
_backingMemberList.Clear();
_memberList.Clear();
foreach (Member CurrentMember in ListOfMembers)
{
_memberList.Add(CurrentMember);
_backingMemberList.Add(CurrentMember);
}
_memberList = new ObservableCollection<Member>(_backingMemberList);
and the binding is simply:
<DataGrid Name="dataGridMembers" ItemsSource="{Binding MemberList}" />
Now, for some reason this breaks the RowStyle
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="{Binding BindsDirectlyToSource=True, Converter={StaticResource BGColor}}"/>
</Setter.Value>
</Setter>
</Style>
</DataGrid.RowStyle>
I don't get any information on the output pane about the binding being right or wrong. I can't figure out what I'm doing wrong.
And just to add to the fun I've got the same hookup on an other page and it breaks the binding altogether. The rows don't even show.
My questions are:
- What am I doing wrong?
- Failing that, how do I debug a data binding?