Silverlight 如何设置Bing Map API层的不透明度,但为图钉对象保留完全100%的不透明度?

Silverlight 如何设置Bing Map API层的不透明度,但为图钉对象保留完全100%的不透明度?,silverlight,silverlight-4.0,bing-maps,bing-api,Silverlight,Silverlight 4.0,Bing Maps,Bing Api,我想通过设置不透明度使航空地图层褪色。 但是,我希望在地图顶部渲染的任何对象(即图钉)都不保留alpha(不透明度) 有人知道这是否可行(API是否以某种方式支持这一点) 谢谢 需要的是一种设置内部MapTileLayer样式的方法,Map控件使用该样式来显示地图本身。不幸的是,API没有提供这种访问级别 但是,我们可以使用VisualTreeHelper访问MapTileLayer。我在此使用extensions类来帮助实现这一点。在项目中有了这个类,我们可以做一些像这样笨拙的事情:-

我想通过设置不透明度使航空地图层褪色。 但是,我希望在地图顶部渲染的任何对象(即图钉)都不保留alpha(不透明度)

有人知道这是否可行(API是否以某种方式支持这一点)


谢谢

需要的是一种设置内部
MapTileLayer
样式的方法,Map控件使用该样式来显示地图本身。不幸的是,API没有提供这种访问级别

但是,我们可以使用VisualTreeHelper访问
MapTileLayer
。我在此使用extensions类来帮助实现这一点。在项目中有了这个类,我们可以做一些像这样笨拙的事情:-

        MapTileLayer tileLayer = myMapControl.Descendents().OfType<MapTileLayer>().FirstOrDefault();
        if (tileLayer != null)
        {
            tileLayer.Opacity = 0.5;  // set the opacity desired.
        }
有了这个衍生工具,我们可以做到:-

<UserControl x:Class="HostBingMaps.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:local="clr-namespace:HostBingMaps"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
    xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl">
  <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <Style x:Key="TileLayerStyle" TargetType="m:MapTileLayer">
                <Setter Property="Opacity" Value="0.2" />
            </Style>
        </Grid.Resources>
        <local:MapEx Mode="Aerial" TileLayerStyle="{StaticResource TileLayerStyle}" AnimationLevel="UserInput" UseInertia="True"  CredentialsProvider="__creds_here__">
              <!-- Pushpins here --> 
      </local:MapEx>
    </Grid>
</UserControl>


图钉将保持完全不透明,但地图图像本身将淡出。

Sweet!下周当我有机会使用这个扩展时,我会检查这个。但是告诉我一件事。什么是VisualTreeHelper?@Alvinfomdiaspar:看酷。谢谢但是这个可视化的树助手看起来一点帮助都没有。我已经编写了递归可视化树爬虫,它看起来比这个更健壮。我是不是错过了一些有用的东西?@Alvinfomdiaspar:你指的是“VisualTreeEnumerator”吗?如果是这样的话,它以什么方式不健壮?有没有一种方法可以做相反的事情?我的意思是,使图钉不可见,例如,当放大很多。谢谢!
<UserControl x:Class="HostBingMaps.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:local="clr-namespace:HostBingMaps"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
    xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl">
  <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <Style x:Key="TileLayerStyle" TargetType="m:MapTileLayer">
                <Setter Property="Opacity" Value="0.2" />
            </Style>
        </Grid.Resources>
        <local:MapEx Mode="Aerial" TileLayerStyle="{StaticResource TileLayerStyle}" AnimationLevel="UserInput" UseInertia="True"  CredentialsProvider="__creds_here__">
              <!-- Pushpins here --> 
      </local:MapEx>
    </Grid>
</UserControl>