I have a custom Attached Property but the Accessors on never being accessed on databinding. Are theses accessors meant to be accessed everytime the attached property changes?
public static readonly DependencyProperty CharacterColumnNumberProperty =
DependencyProperty.RegisterAttached("CharacterColumnNumber", typeof(int), typeof(DragCanvas), new UIPropertyMetadata(1));
public static int GetCharacterColumnNumber(UIElement uiElement)
{
if (uiElement != null)
return (int)uiElement.GetValue(CharacterColumnNumberProperty);
else return 0;
}
public static void SetCharacterColumnNumber(UIElement uiElement, int value)
{
if (uiElement != null)
{
uiElement.SetValue(CharacterColumnNumberProperty, value);
DragCanvas.SetLeft(uiElement, value * 10);
}
}
XAML:
<Setter Property="local:DragCanvas.CharacterColumnNumber" Value="{Binding Path=CharacterColumnNumber, Mode=TwoWay}" />
No they are not. If you want to know when the internal property engine is changing these values you pass in a delegate for the PropertyChangedCallback parameter of the UIPropertyMetadata.
This delegate will be invoked each time the property is changed, whether it came through the CLR property or via changes internally in the dependency property engine (i.e. bindings).