i've got another binding problem. This time I wanted to rebuild the Master-Detail grid shown here:
http://www.codeproject.com/Articles/30905/WPF-DataGrid-Practical-Examples#masterdetail
But I got this Error: The name "AirplaneDataProvider" does not exist in the namespace "clr-namespace:WpfApplicationDataSetTest"
Here's my code
XAML:
<Window x:Class="WpfApplicationDataSetTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplicationDataSetTest"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<ObjectDataProvider x:Key="AirplaneDataProvider" ObjectType="{x:Type local:AirplaneDataProvider}"/>
<ObjectDataProvider x:Key="Airplanes" ObjectInstance="{StaticResource AirplaneDataProvider}" MethodName="GetAirplanes" />
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<DataGrid Name="DGMaster" Grid.Row="0" ItemsSource="{Binding Source={StaticResource Airplanes}}" SelectedValuePath="AirplaneID">
</DataGrid>
</Grid>
c#:
namespace WpfApplicationDataSetTest
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public class AirplaneDataProvider
{
private AirplaneTestDataSetTableAdapters.AirplaneTableAdapter AirTA;
private AirplaneTestDataSet AirTDS;
public AirplaneDataProvider()
{
AirTDS = new AirplaneTestDataSet();
AirTA = new AirplaneTestDataSetTableAdapters.AirplaneTableAdapter();
AirTA.Fill(AirTDS.Airplane);
}
public DataView GetAirplanes()
{
return AirTDS.Airplane.DefaultView;
}
}
}
}
So what am I doing wrong?
Put the AirplaneDataProvider class into separated file.
Now you have it inside MainWindow class. hope that is the problem.