【发布时间】:2013-11-29 06:26:31
【问题描述】:
我有一个 PushPin 的样式
<Style x:Key="PushPinStyle" TargetType="Maps:Pushpin">
<Setter Property="Width" Value="25"/>
<Setter Property="Height" Value="39"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid>
<Image Source="Assets/Point.png" Stretch="Uniform" HorizontalAlignment="Left"/>
<TextBlock Text={Binding Text}/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
我希望 textblock 绑定到 pushpin.text
public void AddPushpin(Location latlong, string title, string description, MapLayer layer,string pinText)
{
try
{
Pushpin p = new Pushpin()
{
Tag = new Metadata()
{
Title = title,
Description = description
}
};
//
p.Style = this.Resources["PushPinStyle"] as Style;
p.Text = pinText; //This should appear in pushpin on top of Image
MapLayer.SetPosition(p, latlong);
p.Tapped += PinTapped;
layer.Children.Add(p);
}
catch (Exception ex)
{
}
}
但我只能看到图像。
如何将 PushPin.text 绑定到样式的 TextBlock 并显示在样式的图像上方?
【问题讨论】:
标签: c# windows-8 winrt-xaml bing-maps