Я новичок в WPF, и это мой первый пост.Я создал класс под названием «Fruit», который происходит от «DependencyObject» и добавляет дополнительное свойство под названием «Apple».Я создал новый пользовательский элемент управления, который включает свойство зависимости, называемое «MyFruit», типа «Fruit».У меня вопрос, как я могу установить значение по умолчанию для свойств в объекте «MyFruit» (т.е. свойство «Apple»? Я хотел бы установить это в XAML, используя объект.
public class Gauge : Control
{
.
.
.
//---------------------------------------------------------------------
#region MyFruit Dependency Property
public Fruit MyFruit
{
get { return (Fruit)GetValue(MyFruitProperty); }
set { SetValue(MyFruitProperty, value); }
}
public static readonly DependencyProperty MyFruitProperty =
DependencyProperty.Register("MyFruit", typeof(Fruit), typeof(CircularGauge), null);
#endregion
}
//-------------------------------------------------------------------------
#region Fruit class
public class Fruit : DependencyObject
{
private int apple;
public int Apple
{
get { return apple; }
set { apple = value; }
}
}
#endregion