The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Developing Universal Windows apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

 none
Some sort of weird error RRS feed

  • Question

  • When I remove the reference to my custom control in the content preview control, which so far has only a Canvas in an otherwise default control then everything works. Otherwise, after I scroll the listbox for a while (About ten items), it crashes.

    I have tried various options, including simplifying it down to almost nothing, and it appears related to using the custom control.  MyChart is the one I remove to remove the error.  The error is some sort of internal XAML error,

    I just discovered when recreating the error that if I scroll the ListBox fairly slowly the error does not occur, but I can cause the error to happen immediately by scrolling fast.

       at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       at MS.Internal.XcpImports.UIElement_Measure_WithDesiredSize(UIElement element, Size availableSize)
       at System.Windows.UIElement.Measure_WithDesiredSize(Size availableSize)
       at System.Windows.Controls.VirtualizingStackPanel.MeasureChild(UIElement child, Size layoutSlotSize)
       at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)

         <ListBox x:Name="listBox1"
                			ItemsSource="{Binding MyTickers}"
                			FontSize="24"
                			Loaded="listBox1_Loaded" 
                           Grid.Row="2" 
                           Margin="0,11,0,10">
                			<ListBox.ItemContainerStyle>
                				<Style TargetType="ListBoxItem">
                					<Setter Property="HorizontalContentAlignment"
                						Value="Stretch" />
                				</Style>
                			</ListBox.ItemContainerStyle>
    
    
                			<ListBox.DataContext>
                				<ViewModels:MainViewModel />
                			</ListBox.DataContext>
    
                			<ListBox.ItemTemplate>
                				<DataTemplate>
                            <Border 
                                BorderBrush="Red"
                                CornerRadius="7" 
                                Margin="12"
                                BorderThickness="3,3,3,3" 
                                Padding="3,3,3,3">
                                    <Grid 
                                        HorizontalAlignment="Stretch"
                						Margin="12"
                                          Width="400"                                      
                                          
                                          Height="300">
    
                                <TextBlock Text="{Binding Name}" Margin="3" VerticalAlignment="Bottom" HorizontalAlignment="Left"></TextBlock>
                                <toolkit:ToggleSwitch x:Name="ToggleSwitchAlarm"
                                                      Header="Alarm"
                                                       
                                                      Background="#FF853333"
                                                      Foreground="#FFDEDEEC"
                                                      BorderBrush="#FF514343"
                                                      ToolTipService.ToolTip="Alarm if ticker STDev changes enough to indicate news"
                                                      BorderThickness="0"
                                                      HorizontalAlignment="Center"
                                                      VerticalAlignment="Top"
                                                      Height="111"
                                                      Width="174"
                                                      FontSize="18"
                                                      Margin="0,0,-50,-10"
                                                      />
                                    <ContentControl Content="{Binding MyChart}" 
                                                                                    
                                            
                                            ></ContentControl>
    
                                   
    
                                    <TextBlock Text="{Binding Symbol}"
                                           VerticalAlignment="Top"
                                           Margin="3"
                                           HorizontalAlignment="Left"></TextBlock>
                                <TextBlock Text="{Binding StdDev}"
                                           Margin="0,0,4,2"
                                           HorizontalAlignment="Right"
                                            
                                           VerticalAlignment="Bottom"
                                          ></TextBlock>                          
                                
                            </Grid>
                            </Border>
                        </DataTemplate>
                			</ListBox.ItemTemplate>
    
    
                		</ListBox>

    Monday, August 25, 2014 6:28 AM

Answers

  • Hi danielsn,

    If you are working wit windows phone , please use LongListSelector control as far as possible. May be your binded data is too much for the old listBox control. Thats why it will display error while scrolling.

    Working with LongListSelector is minimize resource consumption and it will improve the scrolling capability.

    try it.


    Hope that helps
    Please don't forget to up vote answers you like or which help you and mark one(s) which answer your question.

    ---------------------------------------

    M Prabath Maduranga Peiris
    Microsoft Student Partner
    Blogs : prabathsl.blogspot.com

    • Marked as answer by danielsn Monday, August 25, 2014 11:25 PM
    Monday, August 25, 2014 6:51 AM

All replies

  • Hi danielsn,

    If you are working wit windows phone , please use LongListSelector control as far as possible. May be your binded data is too much for the old listBox control. Thats why it will display error while scrolling.

    Working with LongListSelector is minimize resource consumption and it will improve the scrolling capability.

    try it.


    Hope that helps
    Please don't forget to up vote answers you like or which help you and mark one(s) which answer your question.

    ---------------------------------------

    M Prabath Maduranga Peiris
    Microsoft Student Partner
    Blogs : prabathsl.blogspot.com

    • Marked as answer by danielsn Monday, August 25, 2014 11:25 PM
    Monday, August 25, 2014 6:51 AM
  • Okay, I will switch it over. Thank you.
    Monday, August 25, 2014 3:06 PM