Hi
I am building an application to display a datagrid bound to an ObservableCollection of Records, where each record has a Course Object and an ObservableCollection of Results Objects.
The course is changed using an autocomplete box. The results collection is displayed in a Listbox with an IValueConverter implementation to change the colour of the ellipse template based on criteria of the course currently selected.
It works great on loading, but subsequent updates to the course selection via the autocomplete does not trigger a recalculation/refresh of the value converter.
Is there a way to trigger the refresh in XAML. I added UpdateSource=Property changed to the binding of the list box - but this caused a stack overflow (haha).
Here is the code:
<data:DataGrid x:Name="MyDatGrid">
<data:DataGrid.Columns>
<data:DataGridTemplateColumn Header="Results">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding ListOfResults}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Ellipse Width="20" Height="20" Fill="{Binding Converter={StaticResource resultToBrushConverter} }" Stroke="Black" StrokeThickness="1" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
<data:DataGridTemplateColumn Header="Course" >
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Border>
<input:AutoCompleteBox ItemsSource="{Binding Courses, Source={StaticResource coursesSource}}"/>
</Border>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
I managed to subscribe to the LostFocus Event on the autocomplete box and reset a filter that I already have on the datagrid. But isn;t this very inefficient ? Refreshing the view on the datagrid does not have any effect in that method.
Any steps in the right direction are greatly appreciated. Trying to prevent myself going anymore grey :)
Had thoughts of getting the binding expression of the list in the grid and updating it, but no clue ?
Thanks guys