I've been trying to add an item to my datagrid but when I add one it just displays a blank row. When I use msgbox to see the item text it shows the value I want to display. So my question is, why doesn't the datagrid display "test"?
Here's my vb:
Not sure if it's needed to help me but here's my XAML:Code:Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded 'add columns to datagrid Dim linkColumn As New DataGridTextColumn : Dim titleColumn As New DataGridTextColumn linkColumn.Header = "Links:" : titleColumn.Header = "Titles:" linkColumn.Width = DataGrid1.Width / 2 : titleColumn.Width = DataGrid1.Width / 2 linkColumn.Binding = New System.Windows.Data.Binding("Links") : titleColumn.Binding = New System.Windows.Data.Binding("Titles") DataGrid1.Columns.Add(linkColumn) : DataGrid1.Columns.Add(titleColumn) mainTimer.Interval = 5000 : mainTimer.Enabled = True DataGrid1.Items.Add("test") MsgBox(DataGrid1.Items.Item(0).ToString) 'although the datagrid won't show it, this displays "test". why? End Sub
Code:<DataGrid AutoGenerateColumns="False" Height="289" HorizontalAlignment="Left" Margin="10,10,0,0" Name="DataGrid1" VerticalAlignment="Top" Width="481" Grid.ColumnSpan="2" ItemsSource="{Binding}" />




Reply With Quote