Hi,
Your property title is wrong, you should change the property type to String. It will create a type cast error.
I've created a VB version out from this.
Here are some of the snippets:
Code:Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded Dim linkColumn As New DataGridTextColumn : Dim titleColumn As New DataGridTextColumn linkColumn.Header = "Links:" : titleColumn.Header = "Titles:" linkColumn.Width = dataGrid.Width / 2 : titleColumn.Width = dataGrid.Width / 2 linkColumn.Binding = New System.Windows.Data.Binding("Link") : titleColumn.Binding = New System.Windows.Data.Binding("Title") dataGrid.Columns.Add(linkColumn) : dataGrid.Columns.Add(titleColumn) dataGrid.Items.Add(New DataItems() With {.Link = "http://testingme.com", .Title = "mytesting"}) End SubFor the xaml code:Code:Public Class DataItems Private _link As String Public Property Link() As String Get Return _link End Get Set(ByVal l As String) _link = l End Set End Property Private _title As String Public Property Title() As String Get Return _title End Get Set(ByVal t As String) _title = t End Set End Property End Class
Code:<Grid> <DataGrid AutoGenerateColumns="False" Height="289" HorizontalAlignment="Left" Margin="10,10,0,0" Name="dataGrid" VerticalAlignment="Top" Width="481" Grid.ColumnSpan="2" ItemsSource="{Binding }"> </DataGrid> </Grid>
This works fine on my end..
Cheers!





Reply With Quote