5312

Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight

I have a Windows Phone 7 Silverlight application that has a listbox and within the item template it binds another listbox.

<ListBox x:Name="CouponsGrouping"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="Expires" /> <ListBox ItemsSource="{Binding Coupons}" Margin="0,10,0,0"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <HyperlinkButton Content="{Binding StoreName}" HorizontalAlignment="Left"/> <TextBlock Text="{Binding CouponText}" Style="{StaticResource PhoneTextNormalStyle}" /> <TextBlock Text="{Binding CouponType}" Style="{StaticResource PhoneTextNormalStyle}" /> <Button Content="Press me" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox>

When I try to scroll (click and drag) the list from within the inner listbox the parent listbox doesn't scroll. If I scroll by clicking on the "Expires" texbox it scrolls fine. How can I make it so that when I scroll the inner listbox the parent listbox scrolls instead.

Thanks, in advance.

Answer1:

On your child listbox add ScrollViewer.VerticalScrollBarVisibility="Disabled". This prevents the undesired scrolling behavior.

Answer2:

Hey Jonas - Kevin from Tampa, actually I was just looking up this same question. I don't think this is really a poor UX based upon usage. What I did to resolve this was to actually use a grid rather than a stack panel for the data template of the outer ListBox. Then after I put the nested ListBox in the outer DataTemplate, I put a Rectangle with a transparent fill. You just need to make sure your Rectangle is tall and wide enough to mask the inner ListBox. My nested ListBox only has 2-3-4 items so it's really not an issue.

Make sense?

Recommend

  • how to disable link in jquery
  • How can I click on specific (x,y) coordinates on a web page? [duplicate]
  • Where should I install SQL Management Server instances on my development machine?
  • Running WinPhone emulator inside Win10 VMWare
  • Google Maps - Marker Cluster issue
  • Can't put hyperlink in PHP echo statement
  • Is 418 “I'm a teapot” really an HTTP response code?
  • Does Google App Engine use any hypervisor?
  • Hide Flat Rate shipping exclusively for a product category in Woocommerce
  • Using Jquery to cycle through input fields when MaxLength is reached
  • VS Express 2012, Windows Phone 8 SDK: The interface is unknown
  • CTE Query throws Recursion Exhausted error
  • minishift start using HyperV fails when devtools installed on a different drive than /Users
  • Is GPU pass-through possible with docker for Windows?
  • Universal Windows 10 Emulator not starting up OS
  • How to add option to woo commerce edit order page?
  • What are the benefits of a Hypervisor VM?
  • Core Data : inserting Objects crashed in global queue [ARC - iPhone simulator 6.1]
  • SQL Server 2008R2 and creating XML document
  • UWP XAML ImageBrush.imageSource from networkshare
  • Using ListPicker and DataBinding
  • Binding Selected RowCount to TextBlock not Firing OnPropertyChanged after DataGrid Scroll
  • Set step size polar plot matplotlib python
  • Caliburn Micro, How to use ContentControl (or display 'sub' ViewModel) using ViewModel Fir
  • Floated image with variable width and heading with background image
  • how to display data from 1st point on words on y axis for line chart in d3.js
  • Webgrid not refreshing after delete MVC
  • Blackberry - Custom EditField Cursor
  • preg_replace Double Spaces to tab (\\t) at the beginning of a line
  • Custom validator control occupying space even though display set to dynamic
  • How do I alternate colors in Flat List (React Native)
  • Disable Enter in editText android
  • Change multiple background-images with jQuery
  • How to check if every primary key value is being referenced as foreign key in another table
  • jquery mobile loadPage not working
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • Unanticipated behavior
  • Load html files in TinyMce
  • python regex in pyparsing
  • Free memory of cv::Mat loaded using FileStorage API