none
deep earth 扩展PointBase问题 RRS feed

  • 常规讨论

  • 我扩展了PointBase,在app.xaml配置风格如下
    <Style x:Name="TrackPointStyle" TargetType="AHGeometry:TrackPointGeo">
        <!--轨迹点和标签的样式控制-->
        <!--<Setter Property="RenderTransformOrigin" Value="0,1" />-->
        <!--<Setter Property="AnchorPoint" Value="0.5,0.5" />-->
        <Setter Property="Width" Value="500" />
        <Setter Property="Height" Value="200" />
        <Setter Property="Opacity" Value="0.88" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="AHGeometry:TrackPointGeo">
                    <Grid Name ="RootElement">
                        <Grid.RenderTransform>
                            <ScaleTransform x:Name="_ScaleTransform" ScaleX="0" ScaleY="1"/>
                        </Grid.RenderTransform>
                        <Path RenderTransformOrigin="0,1" Fill="#FFFD0C0C" Stretch="Fill" Stroke="Black" Height="8" Width="8" Canvas.Left="21" Canvas.Top="104" Data="M7.5,4 C7.5,5.9329967 5.9329967,7.5 4,7.5 C2.0670035,7.5 0.5,5.9329967 0.5,4 C0.5,2.0670035 2.0670035,0.5 4,0.5 C5.9329967,0.5 7.5,2.0670035 7.5,4 z"/>
                        <Path RenderTransformOrigin="0,1" Fill="#FFED0B0B" Stretch="Fill" Stroke="#FFF51111" Height="43" Width="41" UseLayoutRounding="False" Canvas.Left="26" Canvas.Top="64" Data="M29,104 L69,62"/>
                        <TextBox RenderTransformOrigin="0,1" Name="_TextBox" Background="#CCFFFFFF" Height="24" Width="125" Canvas.Left="67" Canvas.Top="49" Text="TextBox" TextWrapping="Wrap"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    代码如下
        public class TrackPointGeo : PointBase
        {
            protected TextBox _textBox;

            public TrackPointGeo()
            {
                Style = Application.Current.Resources["TrackPointStyle"] as System.Windows.Style;
            }

            public override void OnApplyTemplate()
            {
                base.OnApplyTemplate();
            }

    第一个path为点的样式,第二个path为从第一个path拉一条线,第三个为点的标签我用了textBox,可是显示出来后都在点上,并且第二个path和textBox的中心点都与第一个path相重合。怎么配置才能达到我要的效果?谢谢!

    • 已编辑 jisuanji 2010年4月14日 2:42
    2010年4月12日 7:53

全部回复