0
LongListSelector 컨트롤의 ItemsSource 속성을 업데이트하려고하면 ArgumentNullReference 예외가 발생합니다.LongListSelector의 데이터 바인딩
XAML 코드 :
<phone:LongListSelector x:Name="LongListSelectorMain" Margin="-12,0,0,0" ItemsSource="{Binding Items}" LayoutMode="List">
<phone:LongListSelector.DataContext>
<local:MainViewModel/>
</phone:LongListSelector.DataContext>
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,30">
<TextBlock FontSize="25" Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock FontSize="25" Text="{Binding LineTwo}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock FontSize="25" Text="{Binding LineThree}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
항목 클래스
Public Class ItemViewModel
Implements INotifyPropertyChanged
Private _lineOne As String
''' <summary>
''' Proprietà ViewModel di esempio: questa proprietà viene utilizzata per visualizzare il relativo valore mediante un'associazione.
''' </summary>
''' <returns></returns>
Public Property LineOne() As String
Get
Return _lineOne
End Get
Set(ByVal value As String)
If Not value.Equals(_lineOne) Then
_lineOne = value
NotifyPropertyChanged("LineOne")
End If
End Set
End Property
Private _lineTwo As String
''' <summary>
''' Proprietà ViewModel di esempio: questa proprietà viene utilizzata per visualizzare il relativo valore mediante un'associazione.
''' </summary>
''' <returns></returns>
Public Property LineTwo() As String
Get
Return _lineTwo
End Get
Set(ByVal value As String)
If Not value.Equals(_lineTwo) Then
_lineTwo = value
NotifyPropertyChanged("LineTwo")
End If
End Set
End Property
Private _Skipass As Skipass
''' <summary>
''' Proprietà ViewModel di esempio: questa proprietà viene utilizzata per visualizzare il relativo valore mediante un'associazione.
''' </summary>
''' <returns></returns>
Public Property Skipass() As Skipass
Get
Return _Skipass
End Get
Set(ByVal value As Skipass)
If Not value.Equals(_Skipass) Then
_Skipass = value
NotifyPropertyChanged("Skipass")
End If
End Set
End Property
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Private Sub NotifyPropertyChanged(ByVal propertyName As String)
Dim handler As PropertyChangedEventHandler = PropertyChangedEvent
If Nothing IsNot handler Then
handler(Me, New PropertyChangedEventArgs(propertyName))
End If
End Sub
최종 클래스
의 DataContext
012 34,최종 클래스
당신은 내가 마이크로 소프트가 제공하는 것이 바로 기본 예제를 사용했습니다 ...하지만 난 그 NullReference 받고 있어요 왜 알아낼 수 없습니다 정직하게 볼 수 있듯이.
예외에서 스택 추적을 게시 할 수 있습니까? –