Set custom ScrollViewer property value with AttachedProperty
Question
I retemplated TreeView with my custom ScrollViewer. If I try to set AttachedProperty "ScrollViewer.PanningMode" of TreeView in code-behind, then my custom ScrollViewer doesn't seem to change (PanningMode of ScrollViewer stays the same).
Code-behind:
_treeView.SetValue(ScrollViewer.PanningModeProperty, PanningMode.None);
EDIT
Actually, I solved it like this:
ScrollViewer scrollViewer = _treeView.Template.FindName("ScrollViewer", _treeView) as ScrollViewer;
if (scrollViewer != null)
scrollViewer.PanningMode = PanningMode.None;
But it is not very beautiful and doesn't answer my question.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow