我正在尝试使用 XAML/C# 在 Windows 8 商店应用程序中的 Bing 地图控件上设置中心位置。我遇到了一些文章,解释说您不能在 XAML 中对 center 属性使用绑定,所以我试图在 C# 中设置它。我在工作室中使用默认的 Windows 8 商店应用网格模板。
<FlipView
x:Name="flipView"
AutomationProperties.AutomationId="ItemsFlipView"
AutomationProperties.Name="Item Details"
TabIndex="1"
Grid.RowSpan="2"
ItemsSource="{Binding Source={StaticResource itemsViewSource}}">
<FlipView.ItemContainerStyle>
<Style TargetType="FlipViewItem">
<Setter Property="Margin" Value="0,137,0,0"/>
</Style>
</FlipView.ItemContainerStyle>
<FlipView.ItemTemplate>
<DataTemplate>
<!--
UserControl chosen as the templated item because it supports visual state management
Loaded/unloaded events explicitly subscribe to view state updates from the page
-->
<UserControl Loaded="StartLayoutUpdates" Unloaded="StopLayoutUpdates">
<ScrollViewer x:Name="scrollViewer" Style="{StaticResource HorizontalScrollViewerStyle}" Grid.Row="1">
<!-- Content is allowed to flow across as many columns as needed -->
<common:RichTextColumns x:Name="richTextColumns" Margin="117,0,117,47">
<RichTextBlock x:Name="richTextBlock" Width="560" Style="{StaticResource ItemRichTextStyle}" IsTextSelectionEnabled="False">
<Paragraph>
<Run FontSize="26.667" FontWeight="Medium" Text="{Binding Title}"/>
<LineBreak/>
<Run FontSize="16.667" FontWeight="Light" Text="{Binding EventStartDate,Converter={StaticResource StringConverter},ConverterParameter='{}{0:D}'}"/>
</Paragraph>
<Paragraph LineStackingStrategy="MaxHeight">
<InlineUIContainer>
<!--<Image x:Name="image" MaxHeight="480" Margin="0,20,0,10" Stretch="Uniform" Source="{Binding Image}" AutomationProperties.Name="{Binding Title}"/>-->
<bm:Map Credentials="{StaticResource BingMapsApiKey}" Height="500" Width="560" Margin="0,20,0,10"
ZoomLevel="10" x:Name="myMap">
<bm:Map.Children>
<bm:Pushpin Background="Red">
<bm:MapLayer.Position>
<bm:Location Latitude="{Binding Place.latitude}" Longitude="{Binding Place.longitude}" />
</bm:MapLayer.Position>
</bm:Pushpin>
</bm:Map.Children>
</bm:Map>
</InlineUIContainer>
</Paragraph>
<Paragraph>
<Run FontSize="18.667" FontWeight="Normal" Text="{Binding Place.placeName}"/>
<LineBreak/>
<Run FontSize="16.667" FontWeight="Light" Text="{Binding Place.addressLine1Txt}"/>
<LineBreak/>
<Run FontSize="16.667" FontWeight="Light" Text="{Binding Place.cityName}"/>
<Run FontSize="16.667" FontWeight="Light" Text="{Binding Place.stateProvinceCode}"/>
<Run FontSize="16.667" FontWeight="Light" Text="{Binding Place.postalCode}"/>
<LineBreak/>
<LineBreak/>
<InlineUIContainer>
<HyperlinkButton Margin="-15,0,0,0" NavigateUri="{Binding HomePageUrl}" Content="{Binding HomePageUrl}" />
</InlineUIContainer>
<LineBreak/>
<Run FontWeight="SemiLight" Text="{Binding Content}"/>
</Paragraph>
</RichTextBlock>
我无法找到 FlipView 控件内的 Bing 地图控件 (bm:Map),因此我可以设置中心。我已经使用 VisualTree Helpers 从 codeplex 尝试了 WinRT XAML Toolkit,但没有成功。
任何帮助将非常感激。谢谢。