Usercontrol的模板如下。
<ControlTemplate x:Key="MarkerTemplate" >
<ToggleButton x:Name="btnMarkerPin" Click="btnMarkerPin_Click" >
<ToggleButton.Template>
<ControlTemplate >
<Grid>
<Grid>
<Ellipse Fill="Green" Width="25" Height="25" VerticalAlignment="Center" HorizontalAlignment="Center" ToolTip="{Binding}" />
</Grid>
<Popup x:Name="pop" PlacementTarget="{Binding ElementName=pin}" StaysOpen="True" Placement="Top" VerticalOffset="-4" HorizontalOffset="-4" IsOpen="False" Margin="30,-50,0,0" AllowsTransparency="True" >
<Border Opacity=".7" CornerRadius="5" BorderBrush="Red" BorderThickness="2" Background="Yellow">
<Grid Margin="10">
<Button x:Name="btnLinkMarker" Style="{StaticResource LinkButton}" FontWeight="Bold" Content="{Binding}" />
</Grid>
</Border>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="ToggleButton.IsChecked" Value="True">
<Setter TargetName="pop" Property="IsOpen" Value="true"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ToggleButton.Template>
</ToggleButton>
</ControlTemplate>
点击应该发生在弹出窗口中的 btnLinkMarker 上。如果我引发事件,我会得到一个未设置的异常对象引用。任何人都可以帮忙。我如何提出这个事件?