我有一塊矩形板,我想動態縮放。我可以設置矩形元素的高度和寬度屬性。唯一不合作的財產是保證金..爲什麼我無法綁定保證金屬性?
我試着將我的ViewModel中的相同屬性邊距綁定到寬度,高度和邊距,它只適用於寬度和高度。只要我試圖在矩形的邊距屬性上,它需要大量的時間來加載窗口,它最終顯示沒有任何保證金..
有沒有人知道爲什麼會發生這種情況?
矩形:
<Rectangle Margin="{Binding ElementName=root, Path=DataContext.Margin}" Fill="White" Height="{Binding ElementName=root, Path=DataContext.Margin}" Width="{Binding ElementName=root, Path=DataContext.Margin}"></Rectangle>
物業:
private int _margin = 5;
public int Margin
{
get
{
return _margin;
}
}
一種快速簡單的變通辦法是隻使用'Border'代替Rectangle'的'現在。當我有時間時,我會嘗試重新創建你以後得到的東西,因爲這很好奇。 –