0

I need a listview with multiple buttons for scrolling. E.g.

ScrollToTop Button ScrollUp Button ListView ScrollDown Button ScrollToBottom Button

I have got the buttons working in a WPF application by using the code mentioned here. Now, I need to reuse this by making it a control(lookless?). The layout of the listview and buttons can be horizontal or vertical. Should I use custom control or user control?

Community
  • 1
  • 1
ShipOfTheseus
  • 234
  • 1
  • 10
  • 1
    A user control. You're not really creating a new control, but composing one out of existing controls, and grouping them into a single control for ease of reuse. – Steve Apr 29 '14 at 12:45
  • I'd either be considering button behaviors, i.e. having seprate buttons with Roles - ScrollToTop & ScrollToBottom and a target control - your listview, or perhaps even a higher level of abstraction. The functional ain't worth neither of options as to me. – user3455395 Apr 29 '14 at 13:21
  • Thanks Steve. With the user control, is it possible to have different styles for ListView? i.e. Can we modify the style of ListView when we use the user control? – ShipOfTheseus Apr 29 '14 at 13:50
  • Thanks user3455395. Would you be able to recommend other options than the ones I mentioned? – ShipOfTheseus Apr 29 '14 at 13:51

1 Answers1

1

Here's what I'd recommend.

Don't use any pre-composed elements. Create a behavior ScrollList, accepting two parameters - Direction and Target, Direction will be Top || Bottom, Target you list - again you can use ElementName binding.

The reason why I'd recommend this approach is the actual code required to scroll your list is tiny, while managing layouts via properties in WPF is proved to be mess an anti pattern (yes you can go ControlTemplates, but it's definitely too havy for what you're trying to do).

If behaviors are too complex just consider creating a couple of commands.

user3455395
  • 161
  • 10
  • Thanks much user3455395. I will give it a go and see how it pans out. Really appreciate your help. I cant Vote up your answer yet(as I dont have enough reputations) but this probably is what I need to do. – ShipOfTheseus Apr 29 '14 at 17:11