silverlight自定义标签的问题
Page.xaml:
<UserControl x:Class="chart.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:custom="clr-namespace:chart;assembly=chart"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<Line X1="100" X2="300" Y1="100" Y2="300" Stroke="Red" StrokeThickness="3"></Line>
<custom:Chart></custom:Chart> 些处引用自定义标签
</Grid>
</UserControl>
Chart.cs
public class Chart : ContentControl
{
public Chart()
{
// Create a Line
Line redLine = new Line();
redLine.X1 = 50;
redLine.Y1 = 50;
redLine.X2 = 200;
redLine.Y2 = 200;
// Create a red Brush
SolidColorBrush redBrush = new SolidColorBrush();
redBrush.Color = Colors.Red;
// Set Line's width and color
redLine.StrokeThickness = 4;
redLine.Stroke = redBrush;
// Add line to the Grid.
//LayoutRoot.Children.Add(redLine); (LayoutRoot是Page里的,所以这时用不了)
}
}
为什么<Line X1="100" X2="300" Y1="100" Y2="300" Stroke="Red" StrokeThickness="3"></Line>只要写到xaml中就可以了,而我自定义的标签<custom:Chart></custom:Chart>就显示不出来呢?
我要怎么才能把自定义的标签也能像系统自带的一样显示出来呢。