사용자 정의 클래스 컬렉션의 항목에 바인딩 된 압핀이 포함 된 WP7 앱의 MapItemsControl이있는 맵이 있습니다. 압핀은 DataTemplate을 통해 컬렉션의 항목 속성에 바인딩됩니다.WP7 사용자 정의 클래스 UI 바인딩 문제
컬렉션에서 항목을 추가하거나 제거 할 때 바인딩마다 속성이있는 모든 핀이 올바르게 표시되지만 항목의 속성 만 수정하면 UI가 업데이트되지 않습니다. 바인딩은로드 할 때 원본 항목에서 값을 가져 오는 것처럼 보이지만 소스 컬렉션 항목의 속성이 업데이트 될 때 UI 요소를 업데이트 된 상태로 유지하고 싶습니다.
Dim TempBoxes As ObservableCollection(Of Box)
내지도 컨트롤이 MapItemsControl 있습니다
Public Class Box
Property CurrentColor As Color
Property Location As GeoCoordinate
End Class
그들의 컬렉션있다 : 여기
사용자 정의 클래스의 : 설명하기 위해, 나는 비슷한 예를 만듭니다 그 안에 :
<maps:MapItemsControl Name="BoxControl"
ItemTemplate="{StaticResource BoxTemplate}"
ItemsSource="{Binding TempBoxes}"/>
항목 템플릿은 다음과 같이이다 : 터치 이벤트 핸들러 사이 핀의 색상을 전환
<DataTemplate x:Key="BoxTemplate">
<maps:Pushpin Location="{Binding Location}" ManipulationStarted="BoxTouched">
<maps:Pushpin.Template>
<ControlTemplate>
<Ellipse Width="35" Height="35" Margin="54,148,366,584"
Stretch="Fill" StrokeThickness="4" Stroke="Black"
Fill="{Binding CurrentColor}" />
</ControlTemplate>
</maps:Pushpin.Template>
</maps:Pushpin>
</DataTemplate>
파란색과 빨간색 :
내가 TempBoxes에서 항목을 추가하거나 제거 할 때마다Private Sub BoxTouched(ByVal sender As Object, ByVal e As RoutedEventArgs)
With DirectCast(DirectCast(sender, Pushpin).DataContext, Box)
If .CurrentColor = Colors.Red Then
.CurrentColor = Colors.Blue
Else
.CurrentColor = Colors.Red
End If
End With
End Sub
, 핀이 모든 렌더링 그들이해야하는 것처럼 (eg 컬렉션 항목에 색상을 지정하면 핀에 색상이 표시됩니다.
항목을 누르면 BoxTouched 하위 항목이 트리거되어 항목의 색상이 모음에서 변경되지만 UI는 변경되지 않습니다 (핀 색상은 동일하게 유지됨). 내가 더 좋은 방법을 거기 있으리라 믿고있어
BoxControl.ItemsSource = Nothing
BoxControl.ItemsSource = TempBoxes
:를 BoxTouched
이 색상을 업데이트하기 위해 UI를 얻으려면, 내가 이 같은 것을 추가하여, 다시 핀을 렌더링하기 위해 가야 이 작업을 수행?