How to put image “placemarkers” inside a scrollbar in WPF?

后端 未结 2 1318
栀梦
栀梦 2021-02-14 03:27

I have a long Scroll Viewer and I want to mark important spots with small images on the scroll bar. If the the image is clicked the scroll bar will jump to the corresponding con

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-14 04:08

    To contribute to japfs answer: I solved the update on resize issue: You can use japfs Style and apply a ItemsSource to the ItemControl:

    ItemsSource="{Binding Positions, UpdateSourceTrigger=PropertyChanged}"
    

    Just make sure Positions is of type ObservableCollection and the positions are recalculated in SizeChanged-event. Additionally in that event call (INotifyPropertyChanged interface which should your ViewModel implement)

    OnPropertyChanged("Positions");
    

    Tried it with a List first, but that did not update correctly. Worked with ObservableCollection just fine.

提交回复
热议问题