StyledProperty Setter Not Called in Custom Control #18357
Unanswered
ArtemRazin
asked this question in
Q&A
Replies: 1 comment
-
Yeah this is by design. The Property is just for convenience. If you want to handle some values set, I'd suggest to override OnPropertyChanged or use a ClassHandler in static constructor. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've noticed an unusual behavior in a large project and created a small sample to demonstrate the issue.
When a custom control has a
StyledProperty
and is styled in XAML, the setter of theStyledProperty
is never called.Code Example
To verify this, I added
Debug.Assert(false)
inside the setter.Here's how the control is used in XAML:
The control renders with a green background, but the setter is never called.
Is this expected behavior?
Beta Was this translation helpful? Give feedback.
All reactions