I am making a calendar application that uses a FlipView to go between weeks, and inside each flipview is “Week” object. The Week.xaml is composed of a Grid of 1 row and 7 columns for the days of the week. Each Grid Column contains a ListView that I populate with events that the user can select from. Here’s some code as an example for defining the grids and 1 column (Sunday) This also contains the name of the day and a blank textbox I populate later on with the date. You can see what it looks like as well.
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Sunday-->
<Grid Grid.Column="0" >
<Grid.RowDefinitions>
<RowDefinition Height="80"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Rectangle Grid.Row="0" Fill="#FF0353A8" Stroke="Black" StrokeThickness="5" RadiusX="10" RadiusY="10"/>
<TextBlock Grid.Row="0" Style="{StaticResource DayOfWeek}" Text="Sunday" Margin="10,6,0,38" />
<TextBlock Grid.Row="0" x:Name="SundayNumber" Style="{StaticResource DayOfWeek}" Text="" Margin="10,37,0,7" />
<ListView Name="SundayPanel" ItemTemplate="{StaticResource TaskTemplate}" IsItemClickEnabled="True" ItemClick="Item_Clicked"/>
</Grid>
This works great for populating items in my ListView, however I have a big problem when trying to swipe between weeks using my FlipView. Whenever I swipe left or right with my finger starting on the ListView area in order to change weeks, I get an unhandled exception like below. This does not happen when I use mouse controls to change between FlipViews, only a swiping gesture. I can click forward in back using ListView arrow controls all day with no problem.
The exception **After using the help below I can get a bit more information about the exception: Unhandled exception at 0x0f96a375 in TaskM8.exe: 0xC0000005: Access violation reading location 0x00000000.
This problem does NOT occur if I use an ItemsControl and ItemsPanelTemplate to display my items instead of a ListView, however I have not figured out how to make my individual items clickable and do things with them (I need to be able to navigate to a fullscreen description of the event after it is clicked.). Event handlers like ItemClick do not seem to be available in an ItemsControl.
Does anyone know why I would be getting this exception, or how to implement this with an ItemsControl?
A quick note about things I’ve tried – I’ve tried to replace the areas where a ListView is with nothing, or ItemControls and even with just 1 list view (in say, Friday for example), I will only get an error if I swipe starting where the ListView is. This is not feasible when the entire week page has 7 of them as the user wouldn’t be able to swipe on basically 3/4 of the page 🙁
Thank you for your time.
I won’t pretend to know why you’re getting this error, but I had similar trouble debugging my app as well. You might be able to get more information on the error if you follow the advice in this post.