开发者

WPF select item in a scroll viewer

开发者 https://www.devze.com 2023-02-22 01:13 出处:网络
I have a ScrollViewer with a StackPanel that contains images. Is it possible to select items in the ScrollViewer/StackPanel开发者_JS百科?

I have a ScrollViewer with a StackPanel that contains images. Is it possible to select items in the ScrollViewer/StackPanel开发者_JS百科?

<ScrollViewer x:Name="Gallery" Grid.Column="1"  Grid.Row="0"   
        HorizontalScrollBarVisibility="Hidden" 
        VerticalScrollBarVisibility="Visible" >
    <StackPanel x:Name="GalleryStack"/>
</ScrollViewer>


How exactly? why not use a Listbox?


You should be able to use the Image.BringIntoView method to bring them into the view. But as Elad points out, what you have doesn't really implement "selection" by itself. You could handle the MouseDown event of the Image elements and call the BringIntoView method.

0

精彩评论

暂无评论...
验证码 换一张
取 消