惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
Y
Y Combinator Blog
博客园 - 【当耐特】
V
Visual Studio Blog
GbyAI
GbyAI
V
V2EX
P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
Microsoft Security Blog
Microsoft Security Blog
D
DataBreaches.Net
Hugging Face - Blog
Hugging Face - Blog
A
About on SuperTechFans
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
N
Netflix TechBlog - Medium
aimingoo的专栏
aimingoo的专栏
B
Blog RSS Feed
量子位
MongoDB | Blog
MongoDB | Blog
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件

博客园 - 白沙河

axure 用中继器实现下拉多选框 excel 常用全局变量 win10 x64 python3.6 pycharm 安装statsmodels Oracle 10进制转36进制 概念数据模型设计与逻辑数据模型设计、物理数据模型设计的关系 does not support ASP.NET compatibility 错误 Oracle日志文件管理与查看 oradmin相关用法 Oracle Standby Database 实现方案 c# 调用zebra打印指令 打印到USB端口 win2008 64位 + oracle11G 64位 IIS7.5 配置WEBSERVICE VISIO 2007 修改形状默认字体 自定义模具 c# 解决IIS写Excel的权限问题 EXTJS gridpanel 动态设置表头 vs2008 连接 vss2005 出现 analyze utility 错误的解决方法 韶关旅游攻略 extjs 文件上传对话框显示后,页面出现空白的问题 IE8不能上网的问题 一些事件的评论
WPF CANVAS 内形状的margin为负值时定位不正确的问题
白沙河 · 2012-12-07 · via 博客园 - 白沙河

CANVAS 内形状的margin为负值,需要指定形状的对齐方式。

按如下方式定义xaml,
    <Canvas>        
        <Path x:Name="pathLink" Stroke="Black" StrokeThickness="1"></Path>
        <!--<Path x:Name="pathStart" Fill="Red"></Path>-->
        <Ellipse x:Name="pathStart" Fill="Red" Width="7" Height="7" HorizontalAlignment="Left"  VerticalAlignment="Top"></Ellipse>
        <Path x:Name="pathEnd"></Path>       
        <Line x:Name="testLine" Stroke="Blue"></Line>
    </Canvas>

如果不指定pathStart的对齐方式,在设计时,是按左上角对齐的,但在运行过程中,则变成了居中对齐,会导致pathStart定位不正确。当margin.left或margin.right为负值时,pathStart定位于margin.left/2的位置,划线(蓝色线)指定线条的坐标,定位正确。如下图:

当margin.left或margin.right为正值时,没有这个问题,定位正确。如果这里也是居中定位,那pathStart应该是定位与margin.left*2的位置,但实际上比不是这样。