I have been searching around without finding a fix so here I go.
I have a Windows with a center that contain a UserControl that will fill the general area of my application.
I have a TabControl with multiple TabItem. In each TabItem I have to show different controls including Datagrids.
Here is the sample code of my second TabItem.
<TabItem Header="Suivi" IsSelected="True">
<Grid Background="#FFE5E5E5" >
<DataGrid x:Name="dgSuivi" ItemsSource="{Binding Source=Suivi}" >
<DataGrid.Columns>
<DataGridTextColumn Header="Suivi" Binding="{Binding COD_NOM }" />
<DataGridTextColumn Header="Date planifiée" Binding="{Binding DAT_PLAN}" />
<DataGridTextColumn Header="Date révisée" Binding="{Binding DAT_REVIS}" />
<DataGridTextColumn Header="Date réelle" Binding="{Binding DAT_REEL}" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</TabItem>
My code behind has a filled property called Suivi
Public Property Suivi As ObservableCollection(Of MyType)
and MyType is the following class:
Public Class MyType
Property COD_NOM as String
Property DAT_PLAN as DateTime
Property DAT_REVIS as DateTime
Property DAT_REEL as DateTime
Public Sub New()
COD_NOM_DAT = Nothing
DAT_PLAN = New System.DateTime(9999, 1, 1)
DAT_REVIS = New System.DateTime(9999, 1, 1)
DAT_REEL = New System.DateTime(9999, 1, 1)
End Sub
End Class
When I change to the second TabItem (Suivi) the datagrid is filled with empty lines.
I've been searching to fix this but I think I am missing a notion here. Is my binding done right?
{Binding Path=Suivi}. - Troels Larsen