Answer the question
In order to leave comments, you need to log in
How to set dependency property in WPF?
I have a custom component class containing a dependency property
public partial class FormulaEditor : UserControl
{
public static readonly DependencyProperty FormulaBindingProperty =
DependencyProperty.Register("FormulaBinding", typeof(Formula), typeof(FormulaEditor));
/// <summary>
/// Свойство зависимости для привязки объекта формулы
/// </summary>
public Formula FormulaBinding
{
get
{
return GetValue(FormulaBindingProperty) as Formula;
}
set
{
SetValue(FormulaBindingProperty, value);
ViewModel = new FormulaViewModel(value);
}
}
...
}
public class WorkTypeViewModel : BaseViewModel<WorkTypeViewModel>
{
public int Id { get; set; }
public string Name { get; set; }
public Formula Formula { get; set; }
...
}
<local:FormulaEditor Margin="0" Grid.Row="2" MinWidth="500" MinHeight="250" FormulaBinding="{Binding Path=Formula}"/>
Answer the question
In order to leave comments, you need to log in
WPF does not use the "FormulaBinding" property setter and calls "SetValue()" directly.
You can track changes using the PropertyChangedCallback. Example here:
https://msdn.microsoft.com/en-us/library/system.wi...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question