//File:Window.xaml.vb Imports System Imports System.Collections Imports System.ComponentModel Imports System.Data Imports System.Data.OleDb Imports System.IO Imports System.Globalization Imports System.Windows Imports System.Windows.Controls Imports System.Windows.Data Imports System.Windows.Documents Imports System.Collections.Generic Namespace WpfApplication1 Public Partial Class Window1 Inherits Window Public Sub New() Me.InitializeComponent() End Sub Private myDataSet As DataSet Private Sub OnInit(sender As Object, e As EventArgs) Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\BookData.mdb") Dim adapter As New OleDbDataAdapter("SELECT * FROM BookTable;", conn) myDataSet = New DataSet() adapter.Fill(myDataSet, "BookTable") myListBox.DataContext = myDataSet End Sub Private Sub OnClick(sender As Object, e As RoutedEventArgs) Dim myDataTable As DataTable = myDataSet.Tables("BookTable") Dim row As DataRow = myDataTable.NewRow() row("Title") = "A" row("ISBN") = "0-1111-1111-2" row("NumPages") = 1 myDataTable.Rows.Add(row) End Sub End Class Public Class IntColorConverter Implements IValueConverter Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert Dim numValue As Integer = CInt(value) If numValue < 50 Then Return System.Windows.Media.Brushes.Green Else Return System.Windows.Media.Brushes.Red End If End Function Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack Return Nothing End Function End Class End Namespace