在XAML中使用自定义控件,并在XAML中并赋初始值。
设置OriginLocation,ScaleInterval 属性,可以通过XAML内传初始值
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
public partial class RadarChart : UserControl
{
//原点位置
private static readonly DependencyProperty OriginLocationProperty =
DependencyProperty.Register("OriginLocation", typeof(string), typeof(RadarChart));
//刻度间隔
private static readonly DependencyProperty ScaleIntervalProperty =
DependencyProperty.Register("ScaleInterval",typeof(int),typeof(RadarChart));
public string OriginLocation {
get { return (string)GetValue(OriginLocationProperty); }
set { SetValue(OriginLocationProperty, value); }
}
public int ScaleInterval {
get { return (int)GetValue(ScaleIntervalProperty); }
set { SetValue(ScaleIntervalProperty, value); }
}
}
<components:RadarChart OriginLocation="upleft" ScaleInterval="10" />