WPF自定义依赖集合属性无法触发更新的问题

  通常WPF中通过继承UserControl的来快速创建自定义控件,最近项目上需要设计一个卫星星图显示控件,最终效果如下图所示。完成过程中遇到了自定义集合依赖属性无法触发更新通知的问题,在此记录一下,方便有相同问题的朋友们可以快速解决,也希望有人能发现更好的解决办法。

  为了完成目的,我写了下面一个SateChart自定义控件类,

XAML代码如下:

<UserControl x:Class="WpfApplication1.SateChart"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" >
    <DockPanel Margin="5" LastChildFill="True">
        <StackPanel Margin="1" DockPanel.Dock="Top" Orientation="Horizontal" HorizontalAlignment="Center">
            <Rectangle Fill="Orange" Width="10" Height="10"/>
            <CheckBox Name="bdView" Content="BD-2" Margin="5,0,5,0"  IsChecked="True" Click="bdView_Click"/>
            <Rectangle Fill="Red" Width="10" Height="10"/>
            <CheckBox Name="gpsView" Content="GPS" Margin="5,0,5,0"    IsChecked="True" Click="gpsView_Click"/>
            <Rectangle Fill="Blue" Width="10" Height="10"/>
            <CheckBox Name="glnssView" Content="GLNS" Margin="5,0,5,0"   IsChecked="True" Click="glnssView_Click"/>
        </StackPanel>
        <Viewbox DockPanel.Dock="Bottom" MaxHeight="300" MaxWidth="300">
            <Canvas Name="myCanvas" Width="90" Height="90" >
                <Ellipse Name="e1" Width="90" Height="90" Fill="Black" Stroke="Black"
                                 HorizontalAlignment="Center"/>
                <Ellipse Name="e2" Width="90" Height="90" Fill="Black" Stroke="White"
                                 HorizontalAlignment="Center">
                    <Ellipse.RenderTransform>
                        <ScaleTransform ScaleX="0.8333" ScaleY="0.8333" CenterX="45" CenterY="45"/>
                    </Ellipse.RenderTransform>
                </Ellipse>
                <Ellipse Name="e3" Width="90" Height="90" Fill="Black" Stroke="White"
                                 HorizontalAlignment="Center">
                    <Ellipse.RenderTransform>
                        <ScaleTransform ScaleX="0.6666" ScaleY="0.6666" CenterX="45" CenterY="45"/>
                    </Ellipse.RenderTransform>
                </Ellipse>
                <Ellipse Name="e4" Width="90" Height="90" Fill="Black" Stroke="White"
                                 HorizontalAlignment="Center">
                    <Ellipse.RenderTransform>
                        <ScaleTransform ScaleX="0.5" ScaleY="0.5" CenterX="45" CenterY="45"/>
                    </Ellipse.RenderTransform>
                </Ellipse>
                <Ellipse Name="e5" Width="90" Height="90" Fill="Black" Stroke="White"
                                 HorizontalAlignment="Center">
                    <Ellipse.RenderTransform>
                        <ScaleTransform ScaleX="0.333" ScaleY="0.333" CenterX="45" CenterY="45"/>
                    </Ellipse.RenderTransform>
                </Ellipse>
                <Ellipse Name="e6" Width=
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值