The ScrollViewer
properties (like VerticalScrollMode
, VerticalScrollBarVisibility
, etc) are attached properties (just like AutomationProperties are).
XAML actually provides two methods of setting these properties:
- The property system (
SetValue
and GetValue
)
- The XAML accessor pattern
I find the SetValue
pattern super straightforward:
// C++/CX
this->MyListView->SetValue(ScrollViewer::VerticalScrollModeProperty, ScrollMode::Disabled);
this->MyListView->SetValue(ScrollViewer::VerticalScrollBarVisibilityProperty, ScrollBarVisibility::Hidden);
this->MyListView->SetValue(ScrollViewer::HorizontalScrollModeProperty, ScrollMode::Disabled);
this->MyListView->SetValue(ScrollViewer::HorizontalScrollBarVisibilityProperty, ScrollBarVisibility::Hidden);
(I have not used the other pattern).
This method works for all AttachedProperties (see this similar StackOverflow question).
This works because attached properties are, at their core, DependencyProperties, which provide the SetValue
and GetValue
APIs. From the documentation of attached properties:
Attached properties for the Windows Runtime are implemented as dependency properties, so that the values can be stored in the shared dependency-property store by the property system. Therefore attached properties expose a dependency property identifier on the owning class.