EDN Admin
Well-known member
I wish to create custom tags inheriting Grid and DataGrid. I created a namespace and added it to my project. Then, I put my custom tags into a XAML page, and built the project. It works; but when I try to give my tags a name, I got errors. This is my
code
<div style="background-color:white; color:black
<pre><span style="color:blue Namespace MyNs
<span style="color:blue Public <span style="color:blue Class MyGrid
<span style="color:blue Inherits Grid
<span style="color:blue End <span style="color:blue Class
<span style="color:blue Public <span style="color:blue Class MyDataGrid
<span style="color:blue Inherits DataGrid
<span style="color:blue End <span style="color:blue Class
<span style="color:blue End <span style="color:blue Namespace
[/code]
<pre><Page x:Class="myPage"
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:myns="clr-namespace:MyApp.MyNs"
Title="my Page
<myns:MyGrid>
<myns:MyDataGrid Name="myDg" Width="200" Height="180" HorizontalAlignment="Left" VerticalAlignment="Top
</myns:MyDataGrid>
</myns:MyGrid>[/code]
when I build the project, I get this error:
<pre>"Because MyDataGrid is implemented in the same assembly, you must set the x:Name attribute rather than the Name attribute"[/code]
if I replace Name with x:Name, I get:
<pre>"Type MyApp.MyNs.MyDataGrid is not defined"[/code]
How can I do to give my MyDataGrid element a name? Please help.
View the full article
code
<div style="background-color:white; color:black
<pre><span style="color:blue Namespace MyNs
<span style="color:blue Public <span style="color:blue Class MyGrid
<span style="color:blue Inherits Grid
<span style="color:blue End <span style="color:blue Class
<span style="color:blue Public <span style="color:blue Class MyDataGrid
<span style="color:blue Inherits DataGrid
<span style="color:blue End <span style="color:blue Class
<span style="color:blue End <span style="color:blue Namespace
[/code]
<pre><Page x:Class="myPage"
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:myns="clr-namespace:MyApp.MyNs"
Title="my Page
<myns:MyGrid>
<myns:MyDataGrid Name="myDg" Width="200" Height="180" HorizontalAlignment="Left" VerticalAlignment="Top
</myns:MyDataGrid>
</myns:MyGrid>[/code]
when I build the project, I get this error:
<pre>"Because MyDataGrid is implemented in the same assembly, you must set the x:Name attribute rather than the Name attribute"[/code]
if I replace Name with x:Name, I get:
<pre>"Type MyApp.MyNs.MyDataGrid is not defined"[/code]
How can I do to give my MyDataGrid element a name? Please help.
View the full article