I have the following Code behind of a XAML page:
namespace Paone
{
public partial class Controls : Page
{
public Controls()
{
InitializeComponent();
}
public enum Gender
{
Male,
Female
}
public class Record
{
public string FirstName { get; set; }
public string LastName { get; set; }
public Uri Website { get; set; }
public bool IsBillionaire { get; set; }
public Gender Gender { get; set; }
}
}
}
And the XAML:
<Page x:Class="Paone.Controls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:sys="clr-namespace:System;assembly=System.Runtime"
xmlns:local="clr-namespace:Paone"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="Controls">
...
<DataGrid IsReadOnly="True" Grid.Row="1" Grid.Column="2" >
<DataGrid.Resources>
<ObjectDataProvider x:Key="genderEnum" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type Type="local:Gender" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</DataGrid.Resources>
<!-- The columns: -->
<DataGrid.Columns>
<DataGridTextColumn Header="First Name" Binding="{Binding FirstName}"/>
<DataGridTextColumn Header="Last Name" Binding="{Binding LastName}"/>
<DataGridHyperlinkColumn Header="Website" Binding="{Binding Website}"/>
<DataGridCheckBoxColumn Header="Billionaire?" Binding="{Binding IsBillionaire}"/>
<DataGridComboBoxColumn Header="Gender" SelectedItemBinding="{Binding Gender}" ItemsSource="{Binding Source={StaticResource genderEnum}}"/>
</DataGrid.Columns>
<!-- The data: -->
<local:Record FirstName="Adam" LastName="Nathan" Website="http://twitter.com/adamnathan" Gender="Male"/>
<local:Record FirstName="Bill" LastName="Gates" Website="http://twitter.com/billgates" IsBillionaire="True" Gender="Male"/>
</DataGrid>
As far as I can see, both pieces of code, the code behind page and the XAML deal with the "Paone" namespace. However in the lines:
<x:Type Type="local:Gender" />
As well as:
<local:Record FirstName="Adam" LastName="Nathan" Website="http://twitter.com/adamnathan" Gender="Male"/>
<local:Record FirstName="Bill" LastName="Gates" Website="http://twitter.com/billgates" IsBillionaire="True" Gender="Male"/>
The Enum Gender and the class Record are not recognized by the system...
Why is that?