Я новичок в WPF, и это мой первый пост. Я создал класс под названием "Фрукты", который сходит с "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