也許我在這裏錯過了一些簡單的東西,但我無法找到一種方法從畫布中包含的項目中刪除附加屬性。WPF 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);
這不會起作用,因爲頂部附加屬性優先於底部的附加屬性;所以我們儘量「未設置」頂部附加屬性
//Move the image to the bottom of the canvas
Canvas.SetTop(theImage, DependencyProperty.UnsetValue);
Canvas.SetBtoom(theImage, 0);
...和編譯器抱怨UnsetValue不能轉換爲double。
我在這裏錯過了什麼,我們如何刪除頂部附加屬性?
完美;謝謝! – 2011-03-30 21:36:29