也许我在这里遗漏了一些简单的东西,但是我找不到从画布包含的项目中删除附加属性的方法。
代码示例:
//Add an image to a canvas; set the location to the top
theCanvas.Children.Add(theImage);
Canvas.SetTop(theImage, 0);
//Move the image to the bottom of the canvas
Canvas.SetBtoom(theImage, 0);
这不起作用,因为顶部附加属性优先于底部附加属性;所以我们尝试“取消设置”顶部附加属性
//Move the image to the bottom of the canvas
Canvas.SetTop(theImage, DependencyProperty.UnsetValue);
Canvas.SetBtoom(theImage, 0);
...并且编译器抱怨 UnsetValue 无法转换为双精度值。
我在这里遗漏了什么,我们如何删除 Top 附加属性?