Reputation: 14016
How would I create a control like the example at this site as a User Control?
So, instead of doing this:
<ScrollViewer>
<StackPanel>
<!– Content –>
</StackPanel>
</ScrollViewer>
I could do this:
<ScrollableStackPanel>
<!– Content –>
</ScrollableStackPanel>
Upvotes: 0
Views: 760
Reputation: 50028
It looks like you just need to use a ListBox. You can override the ItemContainterStyle and ListBox.Style to get rid of all the Selected behaviours and backgrounds if you want. Because a ListBox has StackPanel and ScrollViewer in it by default.
Upvotes: 0
Reputation: 564333
Unfortunately, there is no way to do that as a UserControl in WPF. You would need to make a custom control (instead of a user control) based on ItemsControl. It could handle this correctly.
That being said, I don't see much point in this. It's very easy to just put your StackPanel within a ScrollViewer - why reinvent the wheel?
Upvotes: 1