I'm a trying to instantiate an object (that was created in C#) in XAML using the ObjectDataProvi der. Unfortunately, I'm receiving the following error: "The type reference cannot find a public type named 'TYPENAME'". I have a .cs file of the same name as the the TYPENAME.
Here's my XAML:
Here's the C# file for TYPENAME:
So, why exactly is TYPENAME unrecognized in line 9 of the XAML? Am I formatting it incorrectly? I tried setting it up as
but that caused the same bug.
Thanks for the help!
Here's my XAML:
Code:
<Window x:Class="PROJECTNAME.PROJECTFILE"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
xmlns:local="clr-namespace:PROJECTNAME"
Title="PROJECTFILE" Height="500" Width="500">
<Window.Resources>
<ResourceDictionary>
<ObjectDataProvider x:Key="NAME1" ObjectType="{x:Type TYPENAME}"/>
<ObjectDataProvider x:Key="NAME2" ObjectInstance="{StaticResource TYPENAME}" MethodName="METHODNAME"/>
</ResourceDictionary>
</Window.Resources>
<Grid Height="375">
<DockPanel DataContext="{Binding Source={StaticResource TYPENAME}}" Width="440" Margin="10,20,191,35">
<dg:DataGrid Name="DG" ItemsSource="{Binding}"/>
</DockPanel>
<DockPanel Width="85" Height="25" Margin="0,350,0,0">
<Frame Name="Frame"/>
<Button Content="See Posts Info" Click="Button_Click"/>
</DockPanel>
</Grid>
</Window>
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace PROJECTNAME
{
class TYPENAME
{
private AccesDBDataSet data_set;
private AccesDBDataSetTableAdapters.tblTYPENAMETableAdapter TYPENAMEAdapter;
public TYPENAME()
{
data_set = new AccesDBDataSet();
DataTable tblTYPENAME = data_set.Tables[1];
TYPENAMEAdapter = new AccesDBDataSetTableAdapters.TYPENAMEAdapterTableAdapter();
TYPENAMEAdapter.Fill(data_set.tblTYPENAMEAdapter);
}
public DataView METHODNAME()
{
return data_set.tblTYPENAMEAdapter.DefaultView;
}
}
}
Code:
<ObjectDataProvider x:Key="NAME1" ObjectType="{x:Type local:TYPENAME}"/>
Thanks for the help!
Comment