silverlight 在同一程序集下新建一个类文件应用控件问题
我在同一程序集下新建一个类文件
我想做一个创建默认控件模板的实例
代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace SimpleButtonDemo
{
public class SimpleButton : ContentControl
{
public SimpleButton() { }
}
}
在XAML文件里
代码如下:
<UserControl x:Class="SimpleButtonDemo.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:custom="clr-namespace:SimpleButtonDemo; assembly=SimpleButtonDemo"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<custom:SimpleButton>
<custom:SimpleButton.Template>
<ControlTemplate>
<Grid x:Name="RootElement">
<Rectangle x:Name="BodyElement" Width="200" Height="100"
Fill="Lavender" Stroke="Purple" RadiusX="16" RadiusY="16" />
<TextBlock Text="Click Me" HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
</custom:SimpleButton.Template>
</custom:SimpleButton>
<custom:SimpleButton >sa</custom:SimpleButton>
</Grid>
</UserControl>
结果说这问题
The tag 'SimpleButton' does not exist in XML namespace 'clr-namespace:SimpleButtonDemo; assembly=SimpleButtonDemo'. D:\vs 2010 项目\SimpleButtonDemo\SimpleButtonDemo\MainPage.xaml
很郁闷我感觉我应用程序集一点问题都没啊
请高手们指点下