从ObservableCollection中删除项目抛出System.Windows.Markup.XamlParseException:[Line:0 Position:0]

时间:2015-09-10 20:11:53

标签: c# xaml windows-phone-8 windows-phone-8.1

使用带有数据绑定LongListSelector的{​​{1}}时使用VS2013创建的WP8.1应用程序上的XamlParse异常。

一切都很好,直到从集合中删除一个项目。奇怪的是,仅当ObservableCollection位于Grid.Row =“1”时才会生成异常。

如果Canvas位于Grid.Row =“0”,一切都很好。

我用两个数据绑定做了一个简单的例子。

异常


A first chance exception of type 'System.ArgumentException' occurred in System.Windows.ni.dll
Additional information: Value does not fall within the expected range.


-       e   {System.Windows.ApplicationUnhandledExceptionEventArgs} System.Windows.ApplicationUnhandledExceptionEventArgs
+       base    {System.Windows.ApplicationUnhandledExceptionEventArgs} System.EventArgs {System.Windows.ApplicationUnhandledExceptionEventArgs}
-       ExceptionObject {System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0]
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at Microsoft.Phone.Controls.LongListSelector.RealizeDisplayItem(Iterator`1 iterator, RealizeOptions options)
   at Microsoft.Phone.Controls.LongListSelector.RealizedRange.Append(RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.AppendElement(RealizedRange range, RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.HealElements(Rect requireRect, Rect allowRect, Boolean& areBoundsUpdated)
   at Microsoft.Phone.Controls.LongListSelector.Balance(Boolean containerViewport)
   at Microsoft.Phone.Controls.LongListSelector.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
   --- End of inner exception stack trace ---}  System.Exception {System.Windows.Markup.XamlParseException}
-       [System.Windows.Markup.XamlParseException]  {System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0]
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at Microsoft.Phone.Controls.LongListSelector.RealizeDisplayItem(Iterator`1 iterator, RealizeOptions options)
   at Microsoft.Phone.Controls.LongListSelector.RealizedRange.Append(RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.AppendElement(RealizedRange range, RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.HealElements(Rect requireRect, Rect allowRect, Boolean& areBoundsUpdated)
   at Microsoft.Phone.Controls.LongListSelector.Balance(Boolean containerViewport)
   at Microsoft.Phone.Controls.LongListSelector.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
   --- End of inner exception stack trace ---}  System.Windows.Markup.XamlParseException
+       base    {System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0]
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at Microsoft.Phone.Controls.LongListSelector.RealizeDisplayItem(Iterator`1 iterator, RealizeOptions options)
   at Microsoft.Phone.Controls.LongListSelector.RealizedRange.Append(RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.AppendElement(RealizedRange range, RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.HealElements(Rect requireRect, Rect allowRect, Boolean& areBoundsUpdated)
   at Microsoft.Phone.Controls.LongListSelector.Balance(Boolean containerViewport)
   at Microsoft.Phone.Controls.LongListSelector.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
   --- End of inner exception stack trace ---}  System.SystemException {System.Windows.Markup.XamlParseException}
        LineNumber  0   int
        LinePosition    0   int
-       Non-Public members      
+       base    {System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0]
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at Microsoft.Phone.Controls.LongListSelector.RealizeDisplayItem(Iterator`1 iterator, RealizeOptions options)
   at Microsoft.Phone.Controls.LongListSelector.RealizedRange.Append(RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.AppendElement(RealizedRange range, RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.HealElements(Rect requireRect, Rect allowRect, Boolean& areBoundsUpdated)
   at Microsoft.Phone.Controls.LongListSelector.Balance(Boolean containerViewport)
   at Microsoft.Phone.Controls.LongListSelector.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
   --- End of inner exception stack trace ---}  System.SystemException {System.Windows.Markup.XamlParseException}
        _errorCode  2148468948  uint
        _lineNumber 0   int
        _linePosition   0   int
        ErrorCode   2148468948  uint
-       Data    {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
+       [System.Collections.ListDictionaryInternal] {System.Collections.ListDictionaryInternal} System.Collections.ListDictionaryInternal
        IsFixedSize false   bool
        IsReadOnly  false   bool
+       Keys    {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}  System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
+       Values  {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}  System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
        HelpLink    null    string
        HResult -2146233087 int
-       InnerException  {System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0]
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at Microsoft.Phone.Controls.LongListSelector.RealizeDisplayItem(Iterator`1 iterator, RealizeOptions options)
   at Microsoft.Phone.Controls.LongListSelector.RealizedRange.Append(RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.AppendElement(RealizedRange range, RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.HealElements(Rect requireRect, Rect allowRect, Boolean& areBoundsUpdated)
   at Microsoft.Phone.Controls.LongListSelector.Balance(Boolean containerViewport)
   at Microsoft.Phone.Controls.LongListSelector.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)}   System.Exception {System.Windows.Markup.XamlParseException}
+       [System.Windows.Markup.XamlParseException]  {System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0]
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at Microsoft.Phone.Controls.LongListSelector.RealizeDisplayItem(Iterator`1 iterator, RealizeOptions options)
   at Microsoft.Phone.Controls.LongListSelector.RealizedRange.Append(RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.AppendElement(RealizedRange range, RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.HealElements(Rect requireRect, Rect allowRect, Boolean& areBoundsUpdated)
   at Microsoft.Phone.Controls.LongListSelector.Balance(Boolean containerViewport)
   at Microsoft.Phone.Controls.LongListSelector.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)}   System.Windows.Markup.XamlParseException
-       Data    {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
+       [System.Collections.ListDictionaryInternal] {System.Collections.ListDictionaryInternal} System.Collections.ListDictionaryInternal
        IsFixedSize false   bool
        IsReadOnly  false   bool
+       Keys    {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}  System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
+       Values  {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}  System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
        HelpLink    null    string
        HResult -2146233087 int
+       InnerException  null    System.Exception
        Message " [Line: 0 Position: 0]"    string
        Source  "System.Windows"    string
        StackTrace  "   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)\r\n   at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at Microsoft.Phone.Controls.LongListSelector.RealizeDisplayItem(Iterator`1 iterator, RealizeOptions options)\r\n   at Microsoft.Phone.Controls.LongListSelector.RealizedRange.Append(RealizedRange nextRange, Double bottom)\r\n   at Microsoft.Phone.Controls.LongListSelector.AppendElement(RealizedRange range, RealizedRange nextRange, Double bottom)\r\n   at Microsoft.Phone.Controls.LongListSelector.HealElements(Rect requireRect, Rect allowRect, Boolean& areBoundsUpdated)\r\n   at Microsoft.Phone.Controls.LongListSelector.Balance(Boolean containerViewport)\r\n   at Microsoft.Phone.Controls.LongListSelector.MeasureOverride(Size availableSize)\r\n   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)"    string
+       Static members      
+       Non-Public members      
        Message " [Line: 0 Position: 0]"    string
        Source  null    string
        StackTrace  null    string
+       Static members      
-       Non-Public members      
+       [System.Windows.Markup.XamlParseException]  {System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0] ---> System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0]
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at Microsoft.Phone.Controls.LongListSelector.RealizeDisplayItem(Iterator`1 iterator, RealizeOptions options)
   at Microsoft.Phone.Controls.LongListSelector.RealizedRange.Append(RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.AppendElement(RealizedRange range, RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.HealElements(Rect requireRect, Rect allowRect, Boolean& areBoundsUpdated)
   at Microsoft.Phone.Controls.LongListSelector.Balance(Boolean containerViewport)
   at Microsoft.Phone.Controls.LongListSelector.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
   --- End of inner exception stack trace ---}  System.Windows.Markup.XamlParseException
        _className  "System.Windows.Markup.XamlParseException"  string
+       _data   {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
        _dynamicMethods null    object
        _exceptionMethod    null    System.Reflection.MethodBase
        _exceptionMethodString  null    string
        _helpURL    null    string
        _HResult    -2146233087 int
+       _innerException {System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0]
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at Microsoft.Phone.Controls.LongListSelector.RealizeDisplayItem(Iterator`1 iterator, RealizeOptions options)
   at Microsoft.Phone.Controls.LongListSelector.RealizedRange.Append(RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.AppendElement(RealizedRange range, RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.HealElements(Rect requireRect, Rect allowRect, Boolean& areBoundsUpdated)
   at Microsoft.Phone.Controls.LongListSelector.Balance(Boolean containerViewport)
   at Microsoft.Phone.Controls.LongListSelector.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)}   System.Exception {System.Windows.Markup.XamlParseException}
+       _ipForWatsonBuckets 0   System.UIntPtr
        _message    " [Line: 0 Position: 0]"    string
        _remoteStackIndex   0   int
        _remoteStackTraceString null    string
        _source null    string
        _stackTrace null    object
        _stackTraceString   null    string
        _watsonBuckets  null    object
        _xcode  -532462766  int
+       _xptrs  0   System.IntPtr
+       IPForWatsonBuckets  0   System.UIntPtr
        IsTransient false   bool
        RemoteStackTrace    null    string
        WatsonBuckets   null    object
        Handled false   bool
+       Non-Public members      

   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at Microsoft.Phone.Controls.LongListSelector.RealizeDisplayItem(Iterator`1 iterator, RealizeOptions options)
   at Microsoft.Phone.Controls.LongListSelector.RealizedRange.Append(RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.AppendElement(RealizedRange range, RealizedRange nextRange, Double bottom)
   at Microsoft.Phone.Controls.LongListSelector.HealElements(Rect requireRect, Rect allowRect, Boolean& areBoundsUpdated)
   at Microsoft.Phone.Controls.LongListSelector.Balance(Boolean containerViewport)
   at Microsoft.Phone.Controls.LongListSelector.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)



>   System.Windows.ni.dll!MS.Internal.XcpImports.CheckHResult(uint hr)  Unknown
    System.Windows.ni.dll!MS.Internal.XcpImports.SetValue(MS.Internal.IManagedPeerBase obj, System.Windows.DependencyProperty property, System.Windows.DependencyObject doh)    Unknown
    System.Windows.ni.dll!MS.Internal.XcpImports.SetValue(MS.Internal.IManagedPeerBase doh, System.Windows.DependencyProperty property, object obj) Unknown
    System.Windows.ni.dll!System.Windows.DependencyObject.SetObjectValueToCore(System.Windows.DependencyProperty dp, object value)  Unknown
    System.Windows.ni.dll!System.Windows.DependencyObject.SetEffectiveValue(System.Windows.DependencyProperty property, ref System.Windows.EffectiveValueEntry newEntry, object newValue)   Unknown
    System.Windows.ni.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.DependencyProperty property, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, System.Windows.DependencyObject.ValueOperation operation)  Unknown
    System.Windows.ni.dll!System.Windows.DependencyObject.RefreshExpression(System.Windows.DependencyProperty dp)   Unknown
    System.Windows.ni.dll!System.Windows.Data.BindingExpression.SendDataToTarget()  Unknown
    System.Windows.ni.dll!System.Windows.Data.BindingExpression.SourceAcquired()    Unknown
    System.Windows.ni.dll!System.Windows.Data.BindingExpression.System.Windows.IDataContextChangedListener.OnDataContextChanged(object sender, System.Windows.DataContextChangedEventArgs e)    Unknown
    System.Windows.ni.dll!System.Windows.Data.BindingExpression.DataContextChanged(object sender, System.Windows.DataContextChangedEventArgs e) Unknown
    System.Windows.ni.dll!System.Windows.FrameworkElement.OnDataContextChanged(System.Windows.DataContextChangedEventArgs e)    Unknown
    System.Windows.ni.dll!System.Windows.FrameworkElement.OnAncestorDataContextChanged(System.Windows.DataContextChangedEventArgs e)    Unknown
    System.Windows.ni.dll!System.Windows.FrameworkElement.NotifyDataContextChanged(System.Windows.DataContextChangedEventArgs e)    Unknown
    System.Windows.ni.dll!System.Windows.FrameworkElement.OnAncestorDataContextChanged(System.Windows.DataContextChangedEventArgs e)    Unknown
    System.Windows.ni.dll!System.Windows.FrameworkElement.NotifyDataContextChanged(System.Windows.DataContextChangedEventArgs e)    Unknown
    System.Windows.ni.dll!System.Windows.FrameworkElement.OnAncestorDataContextChanged(System.Windows.DataContextChangedEventArgs e)    Unknown
    System.Windows.ni.dll!System.Windows.FrameworkElement.NotifyDataContextChanged(System.Windows.DataContextChangedEventArgs e)    Unknown
    System.Windows.ni.dll!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyProperty dp)   Unknown
    System.Windows.ni.dll!System.Windows.DependencyObject.RaisePropertyChangeNotifications(System.Windows.DependencyProperty dp, object oldValue, object newValue)  Unknown
    System.Windows.ni.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.DependencyProperty property, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, System.Windows.DependencyObject.ValueOperation operation)  Unknown
    System.Windows.ni.dll!System.Windows.DependencyObject.SetValueInternal(System.Windows.DependencyProperty dp, object value, bool allowReadOnlySet)   Unknown
    System.Windows.ni.dll!System.Windows.FrameworkElement.DataContext.set(object value) Unknown
    [Native to Managed Transition]  
    System.Windows.ni.dll!MS.Internal.FrameworkCallbacks.SetPropertyOrAddItem(object target, System.Reflection.PropertyInfo propertyInfo, object value, int typeIndex, string propertyName) Unknown
    System.Windows.ni.dll!MS.Internal.FrameworkCallbacks.SetNonAttachedProperty(object target, string propertyName, object propertyValue, int typeIndex)    Unknown
    System.Windows.ni.dll!MS.Internal.FrameworkCallbacks.SetValueToProperty(object target, string propertyName, object propertyValue, int typeIndex, string attachedDPOwnerNamespace, string attachedDPOwnerAssembly)   Unknown
    System.Windows.ni.dll!MS.Internal.FrameworkCallbacks.SetProperty(System.IntPtr nativeTarget, string propertyName, ref MS.Internal.CValue propertyValue, int typeIndex, string attachedDPOwnerNamespace, string attachedDPOwnerAssembly) Unknown
    [Native to Managed Transition]  
    [Managed to Native Transition]  
    System.Windows.ni.dll!MS.Internal.XcpImports.UIElement_Measure(System.Windows.UIElement element, System.Windows.Size availableSize) Unknown
    System.Windows.ni.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize)   Unknown
    Microsoft.Phone.ni.dll!Microsoft.Phone.Controls.LongListSelector.RealizeDisplayItem(Microsoft.Phone.Controls.Iterator iterator, Microsoft.Phone.Controls.LongListSelector.RealizeOptions options)    Unknown
    Microsoft.Phone.ni.dll!Microsoft.Phone.Controls.LongListSelector.RealizedRange.Append(Microsoft.Phone.Controls.LongListSelector.RealizedRange nextRange, double bottom) Unknown
    Microsoft.Phone.ni.dll!Microsoft.Phone.Controls.LongListSelector.AppendElement(Microsoft.Phone.Controls.LongListSelector.RealizedRange range, Microsoft.Phone.Controls.LongListSelector.RealizedRange nextRange, double bottom) Unknown
    Microsoft.Phone.ni.dll!Microsoft.Phone.Controls.LongListSelector.HealElements(System.Windows.Rect requireRect, System.Windows.Rect allowRect, out bool areBoundsUpdated)    Unknown
    Microsoft.Phone.ni.dll!Microsoft.Phone.Controls.LongListSelector.Balance(bool containerViewport)    Unknown
    Microsoft.Phone.ni.dll!Microsoft.Phone.Controls.LongListSelector.MeasureOverride(System.Windows.Size availableSize) Unknown
    System.Windows.ni.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget, double inWidth, double inHeight, out double outWidth, out double outHeight)   Unknown

Xaml示例

canvas

代码背后

<phone:PivotItem x:Name="PivotMyPage" Header="My Page" >
<Grid x:Name="LayoutMyPage" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <phone:LongListSelector Name="LLS_MyItems" Grid.Row="0" Grid.Column="0" ItemsSource="{Binding myItemCollection}" >
        <phone:LongListSelector.ItemTemplate>
            <DataTemplate x:Name="DataTemplateMyPage">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBlock  Grid.Row="0"  Grid.Column="0" Text="{Binding Title}" HorizontalAlignment="Left" />
                    <Canvas     Grid.Row="1"  Grid.Column="1" Width="50" Height="50" HorizontalAlignment="Center" VerticalAlignment="Center" >
                        <Polyline Canvas.Left="0" Canvas.Top="0" Points="{Binding PC}" Stroke="Gray" StrokeThickness="4" HorizontalAlignment="Center" VerticalAlignment="Center" />
                    </Canvas>
                </Grid>
            </DataTemplate>
        </phone:LongListSelector.ItemTemplate>
    </phone:LongListSelector>
</Grid>

1 个答案:

答案 0 :(得分:0)

这种约束是谨慎的

Points="{Binding PC}"

时会发生什么
  1. PC是否为空?
  2. 绑定无法找到PC?
  3. PC不是空但没有项目?
  4. PC有物品
  5. 我推测代码句柄#4,但不处理1 - 3.通过编码所有具有有效列表的情况至少是谨慎的。