【问题标题】:Switch template based on parent property. Possible?根据父属性切换模板。可能的?
【发布时间】:2011-12-21 05:01:23
【问题描述】:

这是我的场景。使用 Bing 地图控件(MVVM):

<m:Map x:Name="MainMap"
            ZoomLevel="{Binding MapZoomLevel, Mode=TwoWay}"
            Center="{Binding MapCenter, Mode=TwoWay}"
            LogoVisibility="Collapsed"
            CopyrightVisibility="Collapsed"
            CredentialsProvider="{Binding BingApiKey}"
            UseInertia="True" 
            Mode="Road" Grid.Column="2" Grid.RowSpan="5">
            <m:MapItemsControl 
                ItemsSource="{Binding Source={StaticResource WorkLayerData}}">
                <m:MapItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Border m:MapLayer.Position="{Binding Location}"
                                Background="LightPink"  BorderBrush="Black">
                            <TextBlock Text="{Binding DisplayId}" />    
                        </Border>
                    </DataTemplate>
                </m:MapItemsControl.ItemTemplate>
            </m:MapItemsControl>
        </m:Map>

在底部,您会看到我如何通过简单地使用 Border 和 TextBlock 声明 DataTemplate 来绑定我的“自定义”图钉。

我想要的是为同一个项目声明3个模板并根据MainMapZoomLevel属性选择它们

例如,当 ZoomLevel

这是一个简单的想法,但如果可能的话我想知道..

【问题讨论】:

    标签: c# silverlight xaml mvvm bing-maps


    【解决方案1】:

    查看用于 Silverlight 的 DataTemplateSelector 解决方案。

    【讨论】:

      猜你喜欢
      • 2020-05-04
      • 2015-12-07
      • 1970-01-01
      • 1970-01-01
      • 2014-07-11
      • 2020-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多