开发者

clearing a mapItemsControl.Itemtemplate WP7 Maps

hi im recurringly updating this map and i noticed its acumulating items rather than just refreshing all items for example

Im assing items to it by mapz.ItemsSource = App.ViewModel.LocationItems; how do i clear the existing items in mapz before this ?

  <my:Map x:Name="myMap" Height="480" Width="444" CredentialsProvider="NON YE BIZ" 
                        Grid.ColumnSpan="1" LogoVisibility="Collap开发者_运维技巧sed" CopyrightVisibility="Collapsed" Margin="5,0,10,0" VerticalContentAlignment="Top" HorizontalContentAlignment="Left" >
                    <my:MapItemsControl x:Name="mapz" ItemsSource="{Binding LocationItems}" Width="450">
                        <my:MapItemsControl.ItemTemplate>
                            <DataTemplate>
                                <my:Pushpin Name="MyPushPin" Location="{Binding Target_Coordinate}" Content="{Binding Target_NickName}"/>
                    </DataTemplate>
                </my:MapItemsControl.ItemTemplate>
                </my:MapItemsControl>
                </my:Map>


Simply call LocationItems.Clear(). If LocationItems is a ObservableCollection, the map with clear off the already rendered items.

No reason at all to access the UI directly when using data bindings.


The ItemTemplate defines the look-and-feel and general behavior of a control - it is not the control itself. Therefore, you have to look at the collection itself, and not the template. To clear the existing ItemCollection, you need this:

mapz.Items.Clear();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜