也许我在这里错过了一些简单的东西,但我找不到从Canvas中包含的对象中删除已附加属性的方法。
代码示例:
代码示例:
//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);
这不起作用是因为Top附加属性优先于Bottom附加属性,所以我们尝试“取消设置”Top附加属性。
//Move the image to the bottom of the canvas
Canvas.SetTop(theImage, DependencyProperty.UnsetValue);
Canvas.SetBtoom(theImage, 0);
编译器报错:无法将UnsetValue转换为double类型。
我错过了什么?我们如何移除Top附加属性?